Python hits the spot
Peter Hansen
peter at engcorp.com
Sun Jun 23 16:51:57 EDT 2002
Pär Kurlberg wrote:
>
> > It's no wonder that 1000 lines of uncommented code behave like that, taking
> > into account that you were trying to integrate several (Tcl/Tk, Fortran, C,
> > Python) systems in a hurry, and, I presume, not knowing most of them.
>
> Funny you should mention this. On my laptop (IBM Thinkpad with 128
> megs of ram) the following two-liner gets me a lockup (i.e. keyboard
> and mouse completely unresponsive, powertoggle needed):
>
> for i in range(50*1000*1000):
> pass
>
> (I am serious.) Happened some time ago, but I never got around to
> filing a bug report (this thread was a good reminder.)
Given that you're asking it to allocate something like 800MB of
memory, and not all at once but in a list that grows steadily
in size and has to be copied over and over, I'm not at all
surprised it appears to lock up a machine with only 128MB.
You don't need the for loop for this to work either: just
try "biglist = range(50000000)". It took several minutes for
my 96MB Windows 98 machine to manage even 10 million items,
let alone 50 million!
-Peter
More information about the Python-list
mailing list