Saturday, February 16, 2008

Pydev debugger and psyco speedups (target: 1.3.14)

The pydev debugger can now make use of psyco if it's available in the environment (it's actually highly recommended... in tests a 50% improvement in the debugger speed was observed... mainly, all the tracing goes through 2 functions, so, speeding it was pretty straightforward -- after discovering how to integrate it).

Now, this relation is kind of strange: the pydev debugger can make use of psyco, but the debugged code can't (because if it gets compiled, pydev can't trace it).

Until now, a Null() object was added as a psyco module in sys.modules so that clients didn't worry about it, but that had some nasty side effects, so, this version will also change this integration so that clients that rely on psyco don't have to change code: a stub module will replace the psyco module in sys.modules and will mimic it better -- and it'll be installed only after pydev finishes using it to get its optimizations.

14 comments:

Fred Chevitarese said...

Hello! how do i install psyco ?
I´ve try to install with easy_install but have no success!

Thanks!!

Fabio Zadrozny said...

You can get psyco binaries from: http://psyco.sourceforge.net/

Cheers,

Fabio

Anonymous said...

I'd like to disable psyco. How can I do it? Thanks!

Fabio Zadrozny said...

To disable psyco, you have to remove it from your pythonpath.

vak said...

oops, no support for 64-bit architectures and even not planned :(

Fabio Zadrozny said...

That's right, altough I believe that there is interest in that...

I haven't checked it, but it seems there's a psyco v2 that may end up targeting 64 bits (note that I'm just speculating based on http://www.reddit.com/r/programming/comments/91yzd/first_source_release_of_psyco_v2/ )

Anonymous said...

I'm sorry for my ignorance, but how do I tell pydev where to look for psyco? I don't succeed in 'adding psyco to the environment', whatever that means...
Thanks

Fabio Zadrozny said...

To add psyco means that you need dto get the psyco binaries, install it to your python installation and later add the folder containing psyco to your pythonpath.

Anonymous said...

Hi Fabio,

thanks for the nice summary.

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?

Cheers, Christian

Fabio Zadrozny said...

Hi Christian,

It's probably an issue in your pythonpath... if you run a simple program as:

import psyco
print psyco

does it work (if not, it's an issue in the pythonpath).

Note that psyco will only work if python itself is compiled in 32 bits.

Anonymous said...

Hi again,

since the "site-packages" (where psyco was installed to) is in the PYTHONPATH, I think psyco should be accessible by Eclipse (or at least Python programs developed using pydev).

Thanks for the tip about importing psyco in a test script, this gave me the following error:

ImportError: DLL load failed: The specified module could not be found. (check that the compiled extension 'C:\Python26\lib\site-packages\psyco\_psyco.pyd' is for the correct Python version; this is Python 2.6.4)

...does this suggest I'm using the wrong version of one of the components? Sadly it doesn't tell which version it is expecting.

See my previous post for version info.

Cheers,
Christian

Fabio Zadrozny said...

This usually means that python was compiled with one compiler and psyco with another (have you double-checked if you really have the 32 bit python instead of the 64 bit?), unfortunately, it's hard without knowing where you got python and where you got psyco to know if they'd be compatible or not...

Cheers,

Fabio

Anonymous said...

Yes, I have 32-bit version of Python (at least that's what ProcessExplorer is telling me). Does it matter that I have Python 2.6.4 and the latest psyco 1.6 version was written only to support Python 1.5?

I also tried downloading the psyco sources to compile them, but it is complaining it can't find vcvarsall.bat... I wonder if it is worth the effort getting it to compile?

Cheers,
Christian

Fabio Zadrozny said...

Actually, I was checking the Psyco homepage/sourceforge page and it really only provides pre-compiled versions until Python 2.5.

So, you'd have to compile it there... it's worth it if you think the debugger is slow for you (if you think it's fast enough for your uses, then it's not needed).