PEP 255: Simple Generators

Guido van Rossum guido at python.org
Thu Jun 21 09:06:00 EDT 2001


Roman Suzi <rnd at onego.ru> writes:

> I've not been heard or commented. It seems that everybody is happy with
> simple generators (and discuss syntax) while I am not.
> 
> I dare think that proposed gen/generator/def-yield thing is doomed to be
> phased out in some future Python version, because it creates frozen
> context for very narrow task of providing generators and in the future (I
> hope) there will be normal parallel programming in Python, which will
> solve the problem simply and efficiently.
> 
> I am not against PEP 255. The feature is cool. But it is a feature which
> requires new keyword, new function class, etc. In one way or another, it
> modifies function and it implicitely lead to the same syntax beasts
> as in C++/Java/Pascal.
> 
> PEP 255 is not Pythonish enough. 

To the contrary, PDP 255 is very Pythonic: it doesn't try to provide
the theoretically "best" solution, it provides something that is just
as usable in most cases and much easier to implement.  This is the
essence of many of Python's "innovations" over languages like C++ or
Lisp.

Some "Zen of Python" (http://www.python.org/doc/Humor.html#zen) rules
that apply to the situation:

- Simple is better than complex.
- Practicality beats purity.
- Now is better than never.
- If the implementation is easy to explain, it may be a good idea.

(The importance of the latter becomes clear to anyone who has had a
look at Neil Schemenauer's code for generators.)

> Let's better think about more general things like:
> * co-routines (which "generator" is an example, if I understand it 
> correctly)
> * adding parallel programming paradigm (which is even better
> for long term), where objects live their lifes and could serve
> other objects as generators, gatherers, services, etc.
> 
> OOP was made easy by python. I hope parallel programming 
> to be added and made equally easy, without all those
> modifiers and zillion of new keywords and modifiers. 
> 
> Sincerely yours, Roman A.Suzi

I personally don't believe that parallel programming will ever become
the most common way of programming.  I know that *my* mind boggles as
soon as I try to figure out what a piece of code that uses parallel
programming features does, so I expect the same is true for, oh, 99%
of the programmers.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-list mailing list