Trouble with psyco

D

Dick Moores

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
(e-mail address removed)
 
F

F. Petitjean

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?

It seems like a problem with your python code. If you enter 2200 :
max = raw_input("positive integer: ") # "2200"
millions = int(max) # to use for printing result # 2200
max = int(max) * 1000000 # not possible on a 32bits platform
# as it is greater than sys.maxint
So please write : max = int(max) * 1000000L
and choose another name (vmax for instance) which doesn't hide a
builtin. And likewise initialize k as k = 0L
 
S

Steve Holden

Dick said:
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
(e-mail address removed)
$ 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
 
S

Steve Holden

Dick said:
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.
"My car is really great when I use ethanol as the fuel, but I'm
disappoointed it won't go at 1,000 miles an hour".
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?
[...]
One other comment - I'll bet the only reason you don't notice the same
problem without psyco is that you never took the time to try to count
large ranges! I can guarantee you'll see the same performance break.

regards
Steve
 

Members online

Forum statistics

Threads
474,211
Messages
2,571,092
Members
47,693
Latest member
david4523

Latest Threads

Top