Trouble with psyco

Steve Holden steve at holdenweb.com
Mon Nov 22 09:29:20 EST 2004


Dick Moores wrote:

> psyco is acting a bit psycho for me.
> 
> Please see my spinForWeb.py at <http://www.rcblue.com/Python/spinForWeb.py>
> 
> When psyco is in use, entering an integer somewhere between 2000 and 
> 2500 causes my computer to freeze. Not really freeze but the program 
> doesn't finish, and I have to quit with a ^Q.
> 
> psyco is really impressive, but I'm disappointed that I can't 
> demonstrate (to friends) counting with it to numbers above 2 billion.
> 
> If I remark out the "psyco.bind(spin)" line, there's no problem no 
> matter what integer I enter. Can someone explain what the problem with 
> psyco is?
> 
> Windows XP, Python 2.3.4
> 
> Thanks,
> 
> Dick Moores
> rdm at rcblue.com
> 
> 
> 
$ python -c "print 2**31"
2147483648

[Please note this is all theory, as I'm not a psyco user]

You are hitting the limit of your platform's integers. After that Python 
(and, presumably, psyco) starts using longs, which will be considerably 
slower.

In plain Python you probably notice the difference much less, because 
there is less difference between integer ops and long ops when no 
optimization is applied. I presume that psyco (stealing a phrase from 
Tim Peters) "optimizes the snot" out of the integer operations, and the 
transition to longs then becomes much more noticeable.

The alternatives are to use a platform with 64-bit integers or stop 
trying to deal with large integers.

I should thank you for the post, as the statement above about my not 
being a psyco user is no longer true. To test the theory I actually 
installed psyco, and verified that your figure of 2000 isn't accurate - 
an input of 2100 could be processed by the psyco-optimized version in 
9.834 seconds on my machine. An input of 2200 took longer than I cared 
to wait, which I regard as strong evidence that it's crossing the 
integer/long boundary that's biting you.

Given that without psyco it took me almost 41 seconds to process an 
input of 100, I think you should be grateful for what you've got ;-)

regards
  Steve
-- 
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119



More information about the Python-list mailing list