Home > Python > Simple benchmark between Cython and Boost.Python

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.

About these ads
  1. No comments yet.
  1. March 16, 2010 at 8:06 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: