为现有 C/C 创建原型级 Python 绑定的最简单、最高效的方法是什么?图书馆?
我想创建简单的原型级 Python 绑定来评估各种 C/C++ 库。
我需要在 Linux、Windows 和 Mac 上进行实验。
我需要绑定的一些库示例包括 C 或 C++ 库的混合,例如:
- http://www.chokkan.org/software/cdbpp/
- http://sourceforge.net /projects/dbh/
- http://code.google.com/p /smhasher/wiki/MurmurHash3
- http://www.seg.rmit.edu .au/zetair/
- http://dbh.sourceforge.net/
有几个候选那里,例如 swig、ctypes、Boost.Python、pybindgen 和问题已经发布在此处,尽管焦点主要集中在性能上。 将 python - 扩展到 swig,而不是 swig 或 Cython
我比起性能,更关心简单而快速地获得一些东西。
您建议选择什么来快速创建绑定?
I want to create simple prototype-grade Python bindings to evaluate various C/C++ libraries.
I need to experiment on Linux, Windows and Mac.
Some examples of the libs that I need bindings for include a mix of C or C++ libraries such as things like:
- http://www.chokkan.org/software/cdbpp/
- http://sourceforge.net/projects/dbh/
- http://code.google.com/p/smhasher/wiki/MurmurHash3
- http://www.seg.rmit.edu.au/zettair/
- http://dbh.sourceforge.net/
There are several candidates out there, such as swig, ctypes, Boost.Python, pybindgen and questions were already posted here on the topic though the focus has been mostly on performance. Extending python - to swig, not to swig or Cython
I care more about getting something simple and quickly than about performance.
What would you recommend to pick for creating bindings quickly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ctypes 非常适合 C 语言。围绕 C 库制作瘦包装器非常容易与它。
ctypes fits the bill pretty well for C. It's ridiculously easy to make thin wrappers around C libraries with it.
您是否考虑过 Cython?它允许您绑定到静态库,并使用类似于 python 的语言编写绑定。
Have you considered Cython? It lets you bind to static libraries, and write your bindings in a language that looks like python.