ANN: Pyrex 0.4.3
Bjorn Pettersen
BPettersen at NAREX.com
Tue Aug 27 12:08:21 EDT 2002
> From: Skip Montanaro [mailto:skip at pobox.com]
>
> Matthias> What's the reason of introducing a new language
construct
> Matthias> instead of transforming the old one into a pure C loop
> Matthias> wherever possible?
>
> Because Python is highly dynamic:
>
> >>> def myrange(x,y=None,z=None):
> ... return [4.0]
> ...
> >>> import __builtin__
> >>> __builtin__.range = myrange
> >>> for i in range(12):
> ... print i
> ...
> 4.0
>
> When compiling, you can't assume anything about the input
> parameters or return value of range(). You need a new
> construct which says, "this is how to enumerate the integers
> between x and y."
But surely in the context of Pyrex you could make assignment to builtins
illegal? (after all Pyrex isn't Python, it just looks like it <wink>)
-- bjorn
More information about the Python-list
mailing list