{"id":412,"date":"2010-08-07T12:43:08","date_gmt":"2010-08-07T17:43:08","guid":{"rendered":"http:\/\/www.insomnihack.com\/?p=412"},"modified":"2010-08-07T12:43:08","modified_gmt":"2010-08-07T17:43:08","slug":"speed-up-pycharm-debugging-with-psyco","status":"publish","type":"post","link":"http:\/\/www.insomnihack.com\/?p=412","title":{"rendered":"Speed up PyCharm Debugging with Psyco"},"content":{"rendered":"<p>I&#8217;ve been digging what JetBrains is doing with <a href=\"http:\/\/www.jetbrains.com\/pycharm\/\">PyCharm<\/a>, and I&#8217;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&#8217;s console window:<\/p>\n<p>[text]<br \/>\npydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)<br \/>\n[\/text]<\/p>\n<p>What&#8217;s all this now? Are you saying something on my box isn&#8217;t running as fast as it could be? That wouldn&#8217;t do at all.<\/p>\n<p>So, I loaded up my web browser. A quick Google search later and I&#8217;d found the <a href=\"http:\/\/psyco.sourceforge.net\/\">psyco<\/a> project on Sourceforge. Psyco is a specialized Python compiler, created by Armin Rigo who is now working on <a href=\"http:\/\/codespeak.net\/pypy\">PyPy<\/a>. 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 <a href=\"http:\/\/codespeak.net\/pipermail\/pypy-dev\/2009q3\/005288.html\">many  improvements to psyco<\/a>.<\/p>\n<p>At work, I tend to live in Windows or Ubuntu, and at the moment I was working in Windows, so I followed the <a href=\"http:\/\/www.voidspace.org.uk\/python\/modules.shtml#psyco\">link<\/a> over to Michael Foord&#8217;s site where he&#8217;d thrown together some 32-bit Windows binaries for psyco 2.0 on Python 2.4, 2.5, and 2.6. I grabbed the <a href=\"http:\/\/www.voidspace.org.uk\/downloads\/psyco-2.0.0.win32-py2.6.zip\">2.6 version<\/a>, but I didn&#8217;t immediately install it.<\/p>\n<p>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 &#8211; psyco does not as yet work with x64).<\/p>\n<p>I created a new Python project, and copied the pystone.py benchmark file from my Python distribution&#8217;s test folder into it. Here&#8217;s the results of my first non-psyco debugger run.<\/p>\n<p>[text highlight=&#8221;6&#8243;]<br \/>\nC:\/Tools\/Python26\/python.exe &quot;C:\\Program Files (x86)\\JetBrains\\PyCharm 96.742\\helpers\\pydev\\pydevd.py&quot; &#8211;client 127.0.0.1 &#8211;port 13926 &#8211;file C:\/Source\/PsycoTest\/pystone.py<br \/>\nConnected to pydevd (version 1.1)<br \/>\npydev debugger: warning: psyco not available for speedups (the debugger will still work correctly, but a bit slower)<br \/>\npydev debugger: starting<br \/>\nPystone(1.1) time for 50000 passes = 8.70703<br \/>\nThis machine benchmarks at 5742.49 pystones\/second<\/p>\n<p>Process finished with exit code 0<br \/>\n[\/text]<\/p>\n<p>Next, I installed psyco and ran the test again.<\/p>\n<p>[text highlight=&#8221;5&#8243;]<br \/>\nC:\/Tools\/Python26\/python.exe &quot;C:\\Program Files (x86)\\JetBrains\\PyCharm 96.742\\helpers\\pydev\\pydevd.py&quot; &#8211;client 127.0.0.1 &#8211;port 13936 &#8211;file C:\/Source\/PsycoTest\/pystone.py<br \/>\nConnected to pydevd (version 1.1)<br \/>\npydev debugger: starting<br \/>\nPystone(1.1) time for 50000 passes = 5.49379<br \/>\nThis machine benchmarks at 9101.18 pystones\/second<\/p>\n<p>Process finished with exit code 0<br \/>\n[\/text]<\/p>\n<p>Not too shabby. My pystone benchmark went from 5742.49 to 9101.18: a 63% improvement just by installing a Python library! Clearly I&#8217;m going to have to experiment using psyco for some of my own projects.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been digging what JetBrains is doing with PyCharm, and I&#8217;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&#8217;s console window: [text] pydev debugger: warning: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[35,6,25],"_links":{"self":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/412"}],"collection":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=412"}],"version-history":[{"count":0,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=\/wp\/v2\/posts\/412\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.insomnihack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}