One Python 2.1 idea
Rainer Deyke
root at rainerdeyke.com
Mon Dec 25 11:48:25 EST 2000
<rturpin at my-deja.com> wrote in message news:927q24$ond$1 at nnrp1.deja.com...
> In article <mailman.977737448.26875.python-list at python.org>,
> Yes, this is a good performance optimization. BUT it
> requires NO CHANGE in how loops are written. The WRONG
> way to do this is to provide another construct in the
> language, making it more complex, but giving it no
> more expressive power. The RIGHT way to do this is
> for the compiler to recognize the common construct:
>
> for i in range(<exp1>: <exp2>):
>
> The compiler then generates efficient byte code that
> does precisely what you describe. It can generate a
> minimal "ghost" of a list for the iteration, because
> there is no way that future code can do anything else
> with that list.
_range = range
ranges = []
def my_range(*args):
r = _range(*args)
global ranges
ranges.append(r)
__builtins__.range = my_range
--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games - http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor
More information about the Python-list
mailing list