I’ve been digging what JetBrains is doing with PyCharm, and I’m looking forward to the 1.0 release. Almost everyone doing Python development at work has switched to it. I noticed something a while back that peaked my curiosity, though. While debugging, I came across a cryptic message in PyCharm’s console window:
[text]
pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)
[/text]
What’s all this now? Are you saying something on my box isn’t running as fast as it could be? That wouldn’t do at all.
So, I loaded up my web browser. A quick Google search later and I’d found the psyco project on Sourceforge. Psyco is a specialized Python compiler, created by Armin Rigo who is now working on PyPy. Psyco speeds up the execution of most Python programs with a single extension module. Development of psyco was recently taken over by Christian Tismer, who has made many improvements to psyco.
At work, I tend to live in Windows or Ubuntu, and at the moment I was working in Windows, so I followed the link over to Michael Foord’s site where he’d thrown together some 32-bit Windows binaries for psyco 2.0 on Python 2.4, 2.5, and 2.6. I grabbed the 2.6 version, but I didn’t immediately install it.
To gauge the benefit of a psyco-powered debugger versus one without, I first needed to run a baseline benchmark. My work box is a Dell Precision T7400 with an Intel Zeon E5405 @ 2.0Ghz with 8Gb ram on Windows XP SP2 x64. My Python version is 2.6.5 (32-bit – psyco does not as yet work with x64).
I created a new Python project, and copied the pystone.py benchmark file from my Python distribution’s test folder into it. Here’s the results of my first non-psyco debugger run.
[text highlight=”6″]
C:/Tools/Python26/python.exe "C:\Program Files (x86)\JetBrains\PyCharm 96.742\helpers\pydev\pydevd.py" –client 127.0.0.1 –port 13926 –file C:/Source/PsycoTest/pystone.py
Connected to pydevd (version 1.1)
pydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)
pydev debugger: starting
Pystone(1.1) time for 50000 passes = 8.70703
This machine benchmarks at 5742.49 pystones/second
Process finished with exit code 0
[/text]
Next, I installed psyco and ran the test again.
[text highlight=”5″]
C:/Tools/Python26/python.exe "C:\Program Files (x86)\JetBrains\PyCharm 96.742\helpers\pydev\pydevd.py" –client 127.0.0.1 –port 13936 –file C:/Source/PsycoTest/pystone.py
Connected to pydevd (version 1.1)
pydev debugger: starting
Pystone(1.1) time for 50000 passes = 5.49379
This machine benchmarks at 9101.18 pystones/second
Process finished with exit code 0
[/text]
Not too shabby. My pystone benchmark went from 5742.49 to 9101.18: a 63% improvement just by installing a Python library! Clearly I’m going to have to experiment using psyco for some of my own projects.