3 ms·
remember there are ways to squeeze performance out of python, projects like cython for example. you can also make a python library in C... I don't know how prac
by jokoon 13y ago
remember there are ways to squeeze performance out of python, projects like cython for example. you can also make a python library in C... I don't know how practical it is though
- dagw 13y agoIf you have a C function, calling it from python is trivial. It even has great support for passing numpy arrays to functions that expect C arrays, and taking C arrays and treating the like numpy arrays.
- jokoon 13y ago> If you have a C function, calling it from python is trivial. with this ? https://docs.python.org/2/extending/extending.html https://docs.python.org/2/extending/extending.html
- dagw 13y agoI use ctypes with numpy.ctypeslib. The end results aren't as robust as 'real' python extensions (you have keep track of types yourself and write your own python wrappers), but it is much quicker and easier to get started. You don't have to learn anything about the python API, your C code remains 'pure' since it doesn't have to know anything about python and there is almost no boilerplate. For simple one off bindings to C functions it's great, especially if the data you're passing back and forth are numpy arrays. There is also CFFI, which I haven't really used, but lots of people seem to like it.