3 ms·
If you’re just calling C functions or wrapping some C++ classes CPython isn’t very hard — unpack the arguments, call the function, pack up the return value(s).
by UncleEntity 4y ago
If you’re just calling C functions or wrapping some C++ classes CPython isn’t very hard — unpack the arguments, call the function, pack up the return value(s).
Iterator support is a little trickier but not too bad once you have it figured out. Same with overloaded functions. Array access is a bit annoying because there’s two ways to do it and you have to guess the right one if you want slices and other craziness.
Memory management can be a pain but I’d imagine it is like that whenever you’re combining two languages.
I’ve done some pretty complex wrappers and have yet to find something that just isn’t possible (within the limitations of python). I usually get the boilerplate generated from pybindgen and then start on the serious hacking.
Actually… I did find something that wasn’t possible and that was because someone thought it was a good idea to commit the raw buffer interface (whatever it’s called) before it was finished and I wasted a whole lot of time on that before I dug into the python source to figure out why it wasn’t working.