Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> cPython supports inline C

First time I am hearing this. Can you share an example?



https://cffi.readthedocs.io/en/latest/ & https://docs.python.org/3/extending/extending.html

There also is https://github.com/rochacbruno/rust-python-example which is something I want to look into.

As for an example, I'm using Snappy right now, so here you go: https://github.com/andrix/python-snappy/blob/master/snappy/s... & https://github.com/andrix/python-snappy/blob/master/snappy/s...

It still requires you to compile the C part- which is why sometimes you need GCC when you're doing a pip install.


I’ve done a lot of interfacing with C and C++. pybind11 [0] has been the easiest and most effective for me to use. It targets C++, but it’s easy enough to wrap C code with it. Cython brings along a lot more bookkeeping code and overhead in my experience. cffi isn’t bad, but it’s not as flexible/expressive.

[0] https://github.com/pybind/pybind11


CFFI has the huge advantage that you don't need to link against libpython, which in turn allows you to have a single wheel for multiple Python versions.


Cython supports inline C, CPython does not.

Maybe GP got confused?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: