Python's "only one way to do it" philosophy isn't good?

Hrvoje Niksic hniksic at
Fri Jun 29 17:22:28 CEST 2007

Douglas Alan <doug at> writes:

>>>  The downside is that they are not quite as flexible as iterators
>>> (which can be hard to code) and generators, which are slow.
>> Why do you think generators are any slower than hand-coded iterators?
> Generators aren't slower than hand-coded iterators in *Python*, but
> that's because Python is a slow language.

But then it should be slow for both generators and iterators.

> *Perhaps* there would be some opportunities for more optimization if
> they had used a less general mechanism.)

Or if the generators were built into the language and directly
supported by the compiler.  In some cases implementing a feature is
*not* a simple case of writing a macro, even in Lisp.  Generators may
well be one such case.

More information about the Python-list mailing list