Python 'for' loop is memory inefficient
MRAB
python at mrabarnett.plus.com
Sat Aug 15 17:18:24 EDT 2009
John Nagle wrote:
> Hendrik van Rooyen wrote:
>> On Saturday 15 August 2009 03:25:45 Dr. Phillip M. Feldman wrote:
>
>> And while you are about it, you may as well teach them that it is much
>> better to do a multiplication than a division.
>
> Actually, division speed hasn't been much of an issue in years.
> Arithmetic
> has been faster than memory access since CPUs went superscalar. In
> CPython,
> with all the interpreter overhead, you'll probably never notice the
> difference.
>
> I'd thought "xrange" had already been obsoleted, and hadn't realized the
> 2.3 - 2.6 versions of CPython were still doing "range" the hard way, not
> as a generator.
>
It would've broken some existing code, hence it was left until Python 3.
More information about the Python-list
mailing list