> 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?


Yes, the range function creates a tuple with the values you specify and
returns it.  Try using xrange instead.  It returns an object with sequence
properties (the iteration part anyway) without actually using the memory.

--
Robin Dunn
Software Craftsman
[EMAIL PROTECTED]       Java give you jitters?
http://wxPython.org      Relax with wxPython!




_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython

Reply via email to