slowdown on looping
Andrew Dalke
adalke at mindspring.com
Sat Oct 4 03:17:39 EDT 2003
More information about the Python-list mailing list
Sat Oct 4 03:17:39 EDT 2003
- Previous message (by thread): slowdown on looping
- Next message (by thread): slowdown on looping
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Trevor Perrin:
> After running a simple loop around 100-200 million times, there's a
> speed drop of about a factor of 7. This happens within several
> minutes (on a 1.7 Ghz machine), so it's not that hard to see.
Are computers really that fast these days? I'm startled.
Here's what I first thought.
Python's integers in your machine are 32 bit twos-complement
signed integers. The largest number that can represent is
2**31-1 == 2,147,483,648 . If you get beyond that, Python
switches to a 'long', which can store as many digits as you
can feed it memory. Because the math is no longer done as
low-level assembly instructions, the code is slower.
However, that limit is 10 times greater than 200 million, so that
isn't the problem. (Could you double check that you're not
off by an order of magnitude?)
I also wondered if your output was in an IDE which was slowing
down as the screen buffer got more and more flow, but you'll
only have 100 terms on the screen.
So I don't know. Next idea anyone?
Andrew
dalke at dalkescientific.com
- Previous message (by thread): slowdown on looping
- Next message (by thread): slowdown on looping
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list