Thanks guys for your urgent responses.
Gregg
----- Original Message -----
From: "Brian Quinlan" <[EMAIL PROTECTED]>
To: "'Gregg Ward'" <[EMAIL PROTECTED]>
Sent: Saturday, April 28, 2001 12:48 PM
Subject: RE: Newbie question - Python interpreter using a lot of memory when
using range
> range(0,9999999) does return a list with 10,000,000 elements.
>
> You can replace range with xrange e.g.
>
> for i in xrange(0,9999999):
>
> xrange is a special type which creates objects as they are accessed (and
> like all Python objects, they are destroyed when they are no longer in
use).
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Gregg
> > Ward
> > Sent: Friday, April 27, 2001 5:26 PM
> > To: [EMAIL PROTECTED]
> > Subject: Newbie question - Python interpreter using a lot of
> > memory when
> > using range
> >
> >
> > Hi, I'm a newbie to Python and I would like to know if
> > someone can explain
> > to me why the following script starts using in excess of 80Mb
> > of memory,
> > when the for loop is running:
> >
> > import sys
> > import time
> >
> > start=time.time()
> > for i in range(0,9999999) :
> > pass
> > end=time.time()
> > print end-start
> >
> > If I change the top of the range to 999999, the interpreter
> > only uses about
> > 14Mb.
> >
> > Does the interpreter actually generate an individual value
> > for everything in
> > the range 0-9999999?
> >
> > I'm using ActivePython 2.1 on Win2K.
> >
> > Thanks
> >
> >
> >
> > Gregg Ward
> >
> >
> >
> >
> > _______________________________________________
> > ActivePython mailing list
> > [EMAIL PROTECTED]
> > http://listserv.ActiveState.com/mailman/listinfo/activepython
> >
>
>
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython