Skip to content

Comment on The homogenization of scientific computing (2013)parent

Comments

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

If 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.

If you have a C function, calling it from python is trivial.

with this ?

https://docs.python.org/2/extending/extending.html

I 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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.