By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,804 Members | 1,516 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,804 IT Pros & Developers. It's quick & easy.

Trouble with psyco

P: n/a
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
rd*@rcblue.com

Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Mon, 22 Nov 2004 02:07:46 -0800, Dick Moores <rd*@rcblue.com> 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?
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

Thanks,

Dick Moores
rd*@rcblue.com

Jul 18 '05 #2

P: n/a
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
rd*@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
Jul 18 '05 #3

P: n/a
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.
"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
--
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.