Live data from Hacker News

Tools for Accelerating Python

amundblog.blogspot.com

1–4 of 4 posts

Re: Tools for Accelerating Python

#2
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.

Re: Tools for Accelerating Python

#3
After 2 years building an algorithmically intensive desktop app in Python that ships on 3 platforms, my strongest recommendation is to avoid all of these fancy environments that change the way Python is used or internally works, including Stackless, Twisted, SWIG, Psyco, Pyrex, and so on. In my experience they tend to 1) introducing subtle bugs and 2) make traditional debugging more difficult.

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.

Re: Tools for Accelerating Python

#4
post #3

After 2 years building an algorithmically intensive desktop app in Python that ships on 3 platforms, my strongest recommendation is to avoid all of these fancy environments that change the way Python is used or internally works, including Stackless, Twisted, SWIG, Psyco, Pyrex, and so on. In my experience they tend to 1) introducing subtle bugs and 2) make traditional debugging more difficult. Generally very little o…

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...