Simple benchmark between Cython and Boost.Python
Inspired by Dan Sanduleac’s post at stackless.com, I re-ran the benchmark between Cython and Boost.Python.
Basically, Cython is about 7x times faster than Boost.Python, which astonished me.
The benchmark was run at my 13 inch MacBook Pro, with OSX leopard. The softwares I used were all installed with MacPorts:
- boost: 1.42.0 (with +python26 enabled)
- Cython: 0.12
- Python 2.6
- cmake 2.8
I used cmake instead of boost-bjam, which is the recommended build tools for boost.python. I don’t think it would affect the result. When compiling, I had -O3 turned on.
As I said, the benchmark was initially carried out by Dan Sanduleac, but I thought his implementation had some problem, he used directly cython to do arithmetic operation, not the native c++. For fair comparison, we should use Cython and Boost.Python in the same way – binding the C++ python which implemented calculation logic, so that we measure the overhead of binding code much more precisely.