473,387 Members | 1,673 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trouble with psyco

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
3 1632
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: KefX | last post by:
Hey...as for what I'm doing with Python, look at my post "Strange Hotshot problem". To make a long story short, I'm embedding Python in order to write a plugin to a freeware music program; the...
10
by: William S. Perrin | last post by:
I'm a python rookie, anyone have and suggestions to streamline this function? Thanks in advance..... def getdata(myurl): sock = urllib.urlopen(myurl) xmlSrc = sock.read() sock.close() ...
0
by: Jeremy Sanders | last post by:
Hi - I'm trying to build a Psyco rpm on Fedora 1. I try the command xpc5:~/psyco-1.1.1> python setup.py bdist_rpm this fails with: .... copying dist/psyco-1.1.1.tar.gz ->...
7
by: Ivan Voras | last post by:
I have this simple *dumb* benchmark-like program: #import psyco #psyco.full() d = 0.0 for i in xrange(1000000000): d += i print d
2
by: Paulo da Silva | last post by:
When running the following program: #! /bin/env python # -*- coding: iso-8859-15 -*- import psyco psyco.full() def main(): n=eval("123+456")
5
by: Fausto Arinos Barbuto | last post by:
Hi All; I have Psyco (on Windows XP) and now I want to install it on Linux, too. I FTP'd the tarball (tar.gz) from Psyco's site but can't get it compiled. First, I tried the usual "python...
6
by: danmcleran | last post by:
I'm not seeing much benefit from psyco (only 5-10% faster). Maybe this example is too trivial? Can someone give me some pointers as to what kind of code would see a dramatic benefit? Here's the...
3
by: a | last post by:
hi i tried psyco+webpy here is the error that i got please let me know if any of you has success run psyco+webpy thanks import web, psyco urls = ( '/', 'view', '/add','add'
15
by: Steve Bergman | last post by:
Just wanted to report a delightful little surprise while experimenting with psyco. The program below performs astonoshingly well with psyco. It finds all the prime numbers < 10,000,000 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.