Python 'for' loop is memory inefficient

Carl Banks pavlovevidence at gmail.com
Mon Aug 17 21:59:43 CEST 2009


On Aug 17, 12:41 pm, exar... at twistedmatrix.com wrote:
> There's a lot of things in Python that I don't strictly *need*.  That
> doesn't mean that they wouldn't be welcome if I could have them.
> Getting rid of the range/xrange dichotomy would improve things.  Yes, I
> can work around it until the runtime is good enough to let me think
> about an *interesting* problem instead.

You don't have to think about using xrange in a for loop, you just
always use it.

> That makes it a legitimate
> complaint in my eyes.  You're welcome to disagree, of course, but do you
> have an argument more compelling than the one you give here?

I am not arguing in favor of range/xrange, I am saying that it's silly
to complain that the compiler isn't a whole lot more complex than it
is just so it can implemnent a semantically-diconnected special case
just so that you can avoid typing an extra "x".  The cost doesn't even
remotely justify it.


Carl Banks



More information about the Python-list mailing list