[Python-Dev] On the possibility of "optimizing" range() calls in for-loops

Martin v. Löwis martin@v.loewis.de
14 Jun 2003 11:56:50 +0200


Chad Netzer <cnetzer@sonic.net> writes:

> There would have to be logic to determine that the range function
> being used is the builtin range, and not a shadowed version.  I assume
> this can be done in a fairly straightforward manner at compile time.
> I could use advice on whether this is feasible (but see below, first)

It is not. Shadowing may occur well after the module import, by
inserting a name in the globals. If it were feasible, it would have
been done long ago.

Regards,
Martin