Tools for Accelerating Python(amundblog.blogspot.com)
amundblog.blogspot.com
Tools for Accelerating Python
http://amundblog.blogspot.com/2008/11/tools-for-accelerating-python.html
3 comments
There is a difference between doing hardcore data crunching in Python and tweaking performance slightly. If you are doing lots of networking and are not using twisted or stackless then you are an idiot. Psyco can sometimes lead to a significant speedup just by adding a couple of lines of code; this speedup may indicate the need for further tweaking of your data structures or codebase, but sometimes it just works faster using psyco. If you have a couple of hotspots that need speeding up then Pyrex and Cython are good tools to drop down into C for a particular function and they are both very good tools (along with the ctypes modules that is now included in the standard library) for writing interfaces to existing C libraries. Using the "real" C/Python API should be a last resort if you have no other option, but not the first tool you reach for...
There is no silver bullet. It's a nice looking list but pretty useless, it says that you made an original mistake choosing Python, now grab a different technology and rewrite it.
Generally very little of the code needs the burden of any complication beyond "real" Python. Where you specifically need more performance tuning, and you are sure that a different data structure or caching doesn't solve it, and it's not one of the many situations someone else has already made a C module for, I suggest using "real" C, in the standard, well documented, debugged and maintained approach: write a Python module in C using the Python/C API.