On Thu, Oct 27, 2011 at 10:19 PM, Steven D'Aprano <steve@pearwood.info> wrote:
The Cofunction Definitions section does not help me understand the concept at all:
(1) You state that it is a "special kind of generator", but don't give any clue as to how it is special. Does it do something other generators can't do? A cofunction is spelled 'codef' instead of 'def', but what difference does that make to the behaviour of the generator you get? How does it behave differently to other generators?
(2) Cofunctions, apparently, "may" contain yield or yield from. Presumably that means that yield is optional, otherwise it would be "must" rather than "may". So what sort of generator do you get without a yield? The PEP doesn't give me any clue.
Yeah, there need to be more references to big motivating use cases/examples of what people are already doing in this space (i.e. Twisted, greenlet, gevent) and how the PEP helps us move towards making asynchronous I/O with an event loop as easy to use as blocking I/O (with or without threads). Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia