[Python-Dev] Propose updating PEP 284 -- Integer for-loops

Nick Coghlan ncoghlan at gmail.com
Sat Jun 18 12:37:41 CEST 2005


Raymond Hettinger wrote:
> Also, I recommend tightening the PEP's motivation.  There are only two
> advantages, encoding and readability.  The former is only a minor gain
> because all it saves is a function call, an O(1) savings in an O(n)
> context.  The latter is where the real benefits lay.

The introduction of 'enumerate', and the proliferation of better 
iterators that reduce the need for pure-integer loops should be 
adressed in the revised motivation. I know my use of 'range' drops 
close to zero when I'm working with Python versions that supply 
'enumerate'.

Even when I do have a pure integer loop, I'll often assign the result 
of the range/xrange call to a local variable, just so I can give it a 
name that indicates the *significance* of that particular bunch of 
numbers.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.blogspot.com


More information about the Python-Dev mailing list