Wed Mar 24 00:15:33 CET 2004
Skip Montanaro <skip at pobox.com> writes:
> You'll be free to write your generator functions like so:
> def generator(f):
> return f
> def silly_counter(n) [generator]:
> for i in range(10):
> yield n+i
> It will just be a convention you adopt though, not a language rule.
It's a start. Next would be to add something like perl's -w flag,
which checks that the conventions are followed. Finally there can be
a compiler option that tells the optimizer to assume without checking
that the conventions are followed (i.e. if you say that some arg is an
int, then it's really an int). That should allow generating much
better code which has the possibly of crashing if the convention is broken.
More information about the Python-list