generator/coroutine terminology

Marko Rauhamaa marko at pacujo.net
Mon Mar 16 03:52:04 EDT 2015


Ian Kelly <ian.g.kelly at gmail.com>:

> If on the other hand these methods were to be added to the iterator
> protocol, it would just create unnecessary implementation overhead for
> the 99.99% of non-generator iterators that are under no illusions
> about the fact that they aren't coroutines.

Why should

   (x for x in [1, 2, 3])

be a valid coroutine but

   iter([1, 2, 3])

not?

Anyway, calling close() on an iterator can be a necessary requirement
even in ordinary generator usage. Only now they have to know if the
underlying iterator was sired by a generator or some other constructor.


Marko



More information about the Python-list mailing list