Question on periods in strings

John Machin sjmachin at lexicon.net
Thu Mar 12 04:09:00 EDT 2009


On Mar 12, 12:42 pm, "Philip Bloom" <pbl... at crystald.com> wrote:

> The range is not actually a meaningful adjustment as the time results are identical switching out xrange (as I believe they should be since in 2.6 range maps to xrange for the most part according to some of the docs).  

Please do
    import sys; print sys.version
and copy/paste the results into your reply.

Sorry, "in 2.6 range maps to xrange for the most part" is just plain
wrong and/or meaningless. In version X.Y, nothing "maps to" anything
else, for any value of X or Y.

What you may have read is that in 2.X, range() produces a list, and
xrange() produces a magic gadget whose type is 'xrange', and that in
3.X, xrange() has disappeared, range() produces a similar gadget to
what xrange() did, and if you want a list, you have to do list(range
()). This is a very interesting phenomenon, but it *doesn't* mean that
xrange and range are equivalent for your problem.

Note that on my machine (running Python 2.6.1 under Windows XP SP 3)
doing y = range(10000000) grabs about 154MB of memory. In the absence
of any information from you about how much spare memory you have,
Gabriel's point was quite valid.

What are OS (+ version etc) are you running, and how much physical
memory is free when you start running these scripts?

Cheers,
John



More information about the Python-list mailing list