The simplicity of Python and the power of C++ force stark choices on a scientific software stack. There have been multiple developments to mitigate language boundaries by implementing language bindings, but the impedance mismatch between the static nature of C++ and the dynamic one of Python hinders their implementation; examples include the use of user-defined Python types with templated C++ and advanced memory management. The development of the C++ interpreter Cling has changed the way we can think of language bindings as it provides an incremental compilation infrastructure available at runtime. That is, Python can interrogate C++ on demand, and bindings can be lazily constructed at runtime. This automatic binding provision requires no direct support from library authors and offers better performance than alternative solutions, such as PyBind11. ROOT pioneered this approach with PyROOT, which was later enhanced with its successor, cppyy. However, until now, cppyy relied on the reflection layer of ROOT, which is limited in terms of provided features and performance. This paper presents the next step for language interoperability with cppyy, enabling research into uniform cross-language execution environments and boosting optimization opportunities across language boundaries. We illustrate the use of advanced C++ in Numba-accelerated Python through cppyy. We outline a path forward for re-engineering parts of cppyy to use upstream LLVM components to improve performance and sustainability. We demonstrate cppyy purely based on a C++ reflection library, InterOp, which offers interoperability primitives based on Cling and Clang-Repl.


翻译:Python的简洁性与C++的强大能力迫使科学软件栈做出明确选择。为缓解语言界限,已有多种实现语言绑定的开发方案,但C++的静态特性与Python的动态特性之间的阻抗不匹配阻碍了其实施——例如在模板化C++中使用用户自定义Python类型以及高级内存管理。C++解释器Cling的发展改变了我们对语言绑定的思考方式,因为它提供了运行时可用的增量编译基础设施。这意味着Python可以按需查询C++,绑定可在运行时惰性构建。这种自动绑定机制无需库作者直接支持,且比PyBind11等替代方案具有更优性能。ROOT率先采用此方法实现PyROOT,后续由cppyy强化。然而,此前cppyy依赖ROOT的反射层,该层在功能特性和性能方面存在局限。本文提出cppyy语言互操作的下一步发展方向,支持统一跨语言执行环境研究并提升跨语言边界优化机会。我们演示了通过cppyy在Numba加速Python中使用高级C++的方法,勾勒了重构cppyy部分模块以利用上游LLVM组件提升性能与可持续性的路线图。最终展示了完全基于C++反射库InterOp(提供基于Cling和Clang-Repl的互操作原语)的cppyy实现。

0
下载
关闭预览

相关内容

Python是一种面向对象的解释型计算机程序设计语言,在设计中注重代码的可读性,同时也是一种功能强大的通用型语言。
【2022新书】Python数据分析第三版,579页pdf
专知会员服务
256+阅读 · 2022年8月31日
【2022新书】Python DevOps,245页pdf
专知会员服务
91+阅读 · 2022年7月11日
【经典书】高效机器学习,Efficient Learning Machines,263页pdf
Python分布式计算,171页pdf,Distributed Computing with Python
专知会员服务
108+阅读 · 2020年5月3日
【SIGGRAPH2019】TensorFlow 2.0深度学习计算机图形学应用
专知会员服务
41+阅读 · 2019年10月9日
CALDERA 一款对手自动模拟工具
黑白之道
20+阅读 · 2019年9月17日
用 Python 开发 Excel 宏脚本的神器
私募工场
26+阅读 · 2019年9月8日
Pupy – 全平台远程控制工具
黑白之道
43+阅读 · 2019年4月26日
Github项目推荐 | gensim - Python中的主题建模
AI研习社
15+阅读 · 2019年3月16日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
18+阅读 · 2018年12月24日
在Python中使用SpaCy进行文本分类
专知
24+阅读 · 2018年5月8日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
2+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Arxiv
0+阅读 · 2023年5月22日
VIP会员
最新内容
学习数据的几何:形状空间分析数学综述
专知会员服务
7+阅读 · 6月17日
定向能反无人机系统最新发展动态
专知会员服务
7+阅读 · 6月17日
从燃煤战舰到算法战争:水面指挥的永恒要求
专知会员服务
6+阅读 · 6月17日
相关资讯
相关基金
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2013年12月31日
国家自然科学基金
0+阅读 · 2012年12月31日
国家自然科学基金
1+阅读 · 2012年12月31日
国家自然科学基金
2+阅读 · 2012年12月31日
国家自然科学基金
0+阅读 · 2011年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
国家自然科学基金
0+阅读 · 2009年12月31日
Top
微信扫码咨询专知VIP会员