python - PyBind - Python 到 C++ 接口
问题描述
使用 PyBind 从 Python 接口和调用 C++ 代码将使 Python 代码更快是有道理的,但是对于从 C++ 调用的 Python 代码来说是否如此?
换句话说,当从 C++ 调用 Python 代码时,PyBind 是否只提供接口而不是像 Cython 那样提供性能增益?
解决方案
First, code with pybind is NOT always faster than python, it depends on use case(example). Binding has overhead and it might take away all performance gain from calling native C++ code.
No magic happens when you call python code from С++. Same amount of work needs to be done in both cases by same machinery.
推荐阅读
- swift - 没有这样的模块“AWSAppSync”
- forms - 如何在opencart 3.0.2的注册页面上合并名字和姓氏字段?
- python-3.7 - 使用正则表达式模式从文本文件中提取 url
- xamarin.forms - 加载列表项后如何从配置文件保存的模型中设置值
- python-2.7 - 使用python将数据插入SQLite3数据库时如何避免插入重复数据?
- javascript - Javascript 中是否有 Function.caller 的生产安全版本?
- javascript - 在 ESRI 地图中禁用双击放大
- jquery - 表 TD 使用 jquery.ui re-sizable 事件以百分比调整大小
- java - 在 Spring AOP 中,joinPoint.proceed 和 method.invoke 有什么区别?
- java - 如何在android中自定义通知