Monthly Archives: November 2011

A Short Account of Wrapping C++ in Python

For the AI-challenge competition I am participating to, I found that path planning (using A*) was (obviously!) the  slowest part of my Python code.  It turned out that 80% of the computation was spent planning!

So I decided to find some good C++ code, wrap it in  Python and give it a go. The code I decided to use is MicroPather, which is incredibly easy to use and it seems to be pretty fast.  One only has to cope with passing void* around, and everything is easy.

I had heard a lot of good things from Cython, so I decided to give it a try. Alas, although the new support for classes seems promising, wrapping an already existing class and playing with polymorphism proved very hard.

To cut a long story short, I reverted to the old and  good Boost Python. It took me no time at all! Another proof that sticking to old approaches is still the best solution.

BTW, it’s incredible how an old and seldom updated library like boost::python is still so incredibly good by today’s standards and changing APIs!

Next plan: include python hooks in the c++ A* code, to the best of versatility!

Leave a comment

Posted by on November 9, 2011 in Programming


Tags: , , ,