3 ms·
> I much prefer the Python C API. Your other reasons for going with Python make sense, but this one surprises me. Isn't the Python C API's reference counting t
by mwcampbell 10y ago
> I much prefer the Python C API.
Your other reasons for going with Python make sense, but this one surprises me. Isn't the Python C API's reference counting tedious? I've written bindings to C libraries for both Python and Lua. With Python, I always use something higher level than the Python C API, like Cython or ctypes. With Lua, I've cranked out lots of bindings using the Lua C Api directly.
- JoshTriplett 10y agoThe reference counting is annoying, yes; however, it's the cost of allowing C to hold references to Python objects. I find a single call to PyArgs_ParseTuple at the top of a Python C entry point much nicer than referencing various values off the Lua stack as they move around. That said, we're in the process of rewriting as many of those functions as possible from C into Python itself, using ctypes.