question about generators
see_reply_address at something.invalid
Thu Aug 22 08:07:42 CEST 2002
Delaney, Timothy wrote:
> Is it worthwhile to have a construct which can only be used in one specific
> case (yield every element in an iterable object) when the alternative is so
> short? The *only* advantages I can think of is that it could be somewhat
> faster, and wouldn't require a temporary name.
Another advantage would be that it would allow the
optimisation I suggested recently.
It remains to be seen how commonly it could be used
in practice. But a priori there is reason to believe
that it could be fairly common, because it will arise
whenever you want a generator that recurses over some
hierarchical data structure.
The best thing is probably just to keep the idea in
mind, wait for more experience at using generators to
accumulate, and then decide whether it's worth
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
More information about the Python-list