Please comment on Draft PEP for Enhanced Generators

Alex Martelli aleax at aleax.it
Wed Jan 30 11:32:21 EST 2002


"Raymond Hettinger" <othello at javanet.com> wrote in message
news:a38c1u$945$1 at bob.news.rcn.net...
> I have written a draft PEP summarizing proposed enhancements to
generators:
> http://users.javanet.com/~othello/download/genpep.htm
>
> The draft reflects all the comments I've received to date on the threads
> where
> the ideas where first proposed.
>
> Please post your comments (and maybe a little encouragment) here on
> comp.lang.py or email them directly to me.

Neat!  One thing, I believe, needs fixing:


def xmap( fun, *sequences ):
    ...
 for args in xzip( *sequences ):
     yield fun(*args)

has the wrong behavior when the sequences have different lengths.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66448 has
an implementation which I believe satisfies the specs (complicated,
alas, but those specs ARE tricky;-).


Why introduce a new method g.submit(x) rather than allow the
existing g.next to take an optional arg?  I've missed the
rationale for that.


Wouldn't it be nice (without _forcing_ generators to be able
to clone or rewind themselves) to standardize the ways in which
a generator supplies such functionality IF it does?  E.g.,
__copy__ (so one uses clonedgen = copy.copy(originalgen)) for
cloning generator state if supported...


Alex






More information about the Python-list mailing list