New submission from Stefan Behnel:

Currently, CPython tends to assume that generators are always implemented by a 
Python function that uses the "yield" keyword. However, it is absolutely 
possible to implement generators as a protocol by adding send(), throw() and 
close() methods to an iterator.

The problem is that these will usually be rejected by code that needs to 
distinguish generators from other input, e.g. in asyncio, as this code will 
commonly do a type check against types.GeneratorType. Instead, it should check 
for the expected protocol. The best way to achieve this is to extend the 
existing ABCs with a Generator ABC that external generator implementations can 
register on.

Related to issue 24004 (asyncio). Asyncio could provide a backport copy of this 
for older Python versions.

I assume this is considered a new feature that cannot be added to 3.4 anymore?

----------
components: Library (Lib)
files: generator_abc.patch
keywords: patch
messages: 241675
nosy: gvanrossum, haypo, scoder, yselivanov
priority: normal
severity: normal
status: open
title: add a Generator ABC
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file39146/generator_abc.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24018>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to