mardi 2 décembre 2008

How I optimize Python code

I Compyle it :-)

I wrote a library that takes a python string and returns a proxy object that can be used like a python module. Inside the proxy module, there are proxy functions. When a proxy function is called, it looks at the type of its arguments and generates a dll specific to those types.

So you have something like this : python -> C++ -> dll -> really fast code.

How fast? Really fast. Thousands of times faster. Even faster than the C++ code I would normally write. The generated code runs really fast because it's threaded, because the generated code is pretty conservative (C++ compilers like conservative code) and because some image processing functions are recognized as intrinsics. The just-in-time compiler does not support the whole Python language, but it supports enough of it to optimize pretty complex algorithms. I use it mainly to optimize scientific applications, but if you'd like to try it out on other kind of applications (string processing? AI? rendering?) tell me, it may not be a big effort for me to add what's missing.

If you'd like to try out Compyle, send me a message or vist VLAM's website.

2 commentaires:

Anonyme a dit...

I found this site using [url=http://google.com]google.com[/url] And i want to thank you for your work. You have done really very good site. Great work, great site! Thank you!

Sorry for offtopic

Anonyme a dit...
Ce commentaire a été supprimé par un administrateur du blogue.