473,320 Members | 1,846 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,320 software developers and data experts.

can anybody explain this range() speedup (with psyco)

i am doing the problems at
http://www.mathschallenge.net/index.php?section=project
one problem involved finding factors, i used

def divisors(n):
divisors = set([1])
for i in range(1, math.ceil(n ** 0.5)+1):
if n % i == 0:
divisors.add(i)
divisors.add(n/i)
return divisors

and it took 16s to solve the task, not too bad.
using psyco brought this down to 5s, nice
i tried it in ironpython and got an error in the range() function,
which i corrected by changing it to
for i in range(1, int(n ** 0.5)+1):
and ironpython took 9s.

when i reran this in psyco, i got a 2x speed improvement (down to 2s)

ive just noticed after leaving idle that there is a depreciation
warning about non-int args to range(), but my question is, why can me
bunging a int( ) in there be faster than whatever python does to
non-int args?

where can i get info on performance of algorithms, ideally with ref to
python, etc?
ive got Python Programming:An intro to computer science, but it seems a
bit basic. anybody know of good unis/colleges using python on their com
sci courses?

its nice to look at the forums on the mathschallenge page and see how
python is the sweet spot between concise/readable. ive been tempted by
ruby but it does not scan nearly as well.

Jul 28 '06 #1
0 1109

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Han Benjamin | last post by:
Is anyone aware of any effort in bringing Psyco onto other platforms, esp. PowerPC (Mac OS X)? I checked the website but it's still stated as X86 only. Thanks, Ben
0
by: Buday Gergely | last post by:
Hi, I run an ubuntu hoary linux. I have psyco installed as apt-get says, but when I launch python and try "import psyco" it does not find. I have tried "locate psyco" to find its source or...
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...
22
by: Alex Martelli | last post by:
I have fixed almost all of the outstanding bugreports and feature request for gmpy: divm doesn't leak memory any more, truediv and floordiv are implemented for all types, etc -- in the current CVS...
118
by: 63q2o4i02 | last post by:
Hi, I've been thinking about Python vs. Lisp. I've been learning Python the past few months and like it very much. A few years ago I had an AI class where we had to use Lisp, and I absolutely...
3
by: DurumDara | last post by:
Hi ! I need to speedup my MD5/SHA1 calculator app that working on filesystem's files. I use the Python standard modules, but I think that it can be faster if I use C, or other module for it. ...
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 ...
2
by: Joe Goldthwaite | last post by:
I've been playing with Python a bit. Doing little performance benchmarks and working with Psyco. It's been fun and I've been learning a lot. For example, in a previous post, I was looking for a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.