[Pythonmac-SIG] Speed up Python on the Mac?

konrad.hinsen@laposte.net konrad.hinsen at laposte.net
Tue Dec 6 20:47:30 CET 2005

On 06.12.2005, at 18:07, Louis Pecora wrote:

> I know about the profiling and find the bottlenecks approach, but then
> the choices of what to do are not clear.  I have in the past written a
> few C modules and turned them into importable Python modules, but that
> was really time consuming and frustrating.
> I see there are many other approaches (SWIG, Pyrex, Psyco -- some may
> not be available on the Mac), so I thought I would start here to ask
> what people in this email list use and recommend.

Pyrex will make the experience of moving from Python to C modules  
much more pleasant. You can start with a pure Python version and then  
migrate line by line to C written in near-Python syntax. It also  
takes care of all the boring bookkeeping, and it is portable - it  
works on the Mac and elsewhere.

SWIG is of practical use only if you already have a C library that  
does the job you want to accelerate. And even then, it may be easier  
to write the interface in Pyrex.

Psyco is for Intel architectures only.

> I do number crunching/scientific programming using BBEdit and the  
> Apple
> supplied Python.  I do not need to squeeze every last CPU cycle out of
> my Mac, just get a good speedup ratio (roughly 5X or better).

I do number crunching as well, and found Pyrex the most useful tool  
once the possibilities of optimizing the Python code seemed exhausted.


More information about the Pythonmac-SIG mailing list