Python 'for' loop is memory inefficient

John Nagle nagle at animats.com
Sat Aug 15 15:34:15 EDT 2009


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.

					John Nagle



More information about the Python-list mailing list