insomnihack

When sleep eludes, the keyboard beckons

Speed up PyCharm Debugging with Psyco

August 7, 2010 Dale 4 Comments

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.

Programming PyCharm, Python, tools

Comments

  1. Christian says

    February 1, 2011 at 5:50 PM

    Hi Dale,

    thanks for the nice summary and congrats for the speed improvement.

    Sadly, I was not able to get the thing to work (that is, the warning didn’t go away) with my setup, which is:
    – Python 2.6.4 (32-bit version)
    – psyco 1.6
    – pydev 1.6.4
    – Windows 7 (64-bit)

    I installed psyco in the default directory which it seemed to have picked correctly as C:\Python26\Lib\site-packages and this is (also by default) part of pydev’s “System PYTHONPATH”.

    Any clues? Could it be a psyco/Python version issue? Or a 32/64-bit problem?

  2. Christian says

    February 1, 2011 at 5:58 PM

    Sorry, I just realised that you’re talking about PyCharm, not about PyDev under Eclipse… my apologies. Will try and ask at another (more relevant) place.

  3. Hugo says

    October 23, 2011 at 11:41 PM

    Thank you for this tip! Now Pycharm debugs like visual studio 😀

  4. sucheth misquith says

    December 22, 2011 at 2:06 AM

    hi Dale,
    Nice blog. Clear explanation. Good one. Thank u.

Leave a Reply

Your email address will not be published. Required fields are marked *

About Me

Hi, my name's Dale, and this is my tech blog. Read More…

Search

Tags

blogging c# database Django documentation Email furniture git hacks htpc IPython Linux mac nas packaging PyCharm Python Roleplaying tools twitter unit tests virtualenv Visual Studio vmware Windows

Copyright © 2025 · Equilibre Theme on Genesis Framework · WordPress · Log in