3 ms·
Can anyone point to an introduction to CPython internals? My goal is to write a Python extension in C that manipulates Python objects.
by aportnoy 8y ago
Can anyone point to an introduction to CPython internals? My goal is to write a Python extension in C that manipulates Python objects.
- mjw1007 8y agoThe official docs aren't bad. https://docs.python.org/3/extending/index.html https://docs.python.org/3/extending/index.html
- pvg 8y agoDepending on what you're trying to do, Cython might be a slightly easier option as well.
- zerkten 8y agoThere is a full course on the subject at http://www.pgbovine.net/cpython-internals.htm http://www.pgbovine.net/cpython-internals.htm.
- AdamM12 8y agoThis looks really interesting. Saving for later as I've been wanting to dive into python much more.
- Too 8y agoTry boost-python, SWIG or cython instead. They give you a nicer c++ api and automatically handles ref-counting, exception handling and other things that are easy to forget. https://www.boost.org/doc/libs/1_61_0/libs/python/doc/html/tutorial/index.html#tutorial.quickstart https://www.boost.org/doc/libs/1_61_0/libs/python/doc/html/t...
- eesmith 8y agoHow is the Boost/PyPy integration? Sure, there's cpyext, so in principle a Boost-generated extension can be used by pypy. Are there any changes which would make Boost-based extensions better integrated/supported by PyPy? The linked-to document only talks about Cython and cffi.
- mattip 8y agoThere is cppyy, which is cffi for c++. Boost python is not being maintained, in the cpython world pybind11 is more popular but cppyy is pypy freindly
- eesmith 8y agoBoost isn't being maintained? I did not know that. One of the project I use often - F/OSS but I'm a user, not core developer - uses Boost for C++/Python integration. They chose it many years ago. This topic has never come up on the mailing list or user group meetings. I suspect that since Boost "just works", no one has care to re-evaluate that decision. Thanks for the pointers to what's going on in the C++/python integration layer. I'll experiment with it.