Calling C/C++ from Python?

2018-12-31 03:28发布

What would be the quickest way to construct a Python binding to a C or C++ library?

(I am using Windows if this matters.)

标签: c++ python c
14条回答
唯独是你
2楼-- · 2018-12-31 03:53

I think cffi for python can be an option.

The goal is to call C code from Python. You should be able to do so without learning a 3rd language: every alternative requires you to learn their own language (Cython, SWIG) or API (ctypes). So we tried to assume that you know Python and C and minimize the extra bits of API that you need to learn.

http://cffi.readthedocs.org/en/release-0.7/

查看更多
深知你不懂我心
3楼-- · 2018-12-31 03:56

One of the official Python documents contains details on extending Python using C/C++. Even without the use of SWIG, it’s quite straightforward and works perfectly well on Windows.

查看更多
登录 后发表回答