generator slides review

Terry Reedy tjreedy at
Sun Feb 2 02:08:16 CET 2014

On 2/1/2014 9:12 AM, andrea crotti wrote:
> I'm giving a talk tomorrow @Fosdem about generators/iterators/iterables..
> The slides are here (forgive the strange Chinese characters):
> and the code I'm using is:
> and the tests:
> If anyone has any feedback or want to point out I'm saying something
> stupid I'd love to hear it before tomorrow (or also later I might give
> this talk again).


The use is assert in the first slide seem bad in a couple of different 

The use of 'gen_even' before it is defined.

A generator expression evaluates (better than 'yields') to a generator, 
not just an iterator.

The definition of 'generator' copies the wrong and confused glossary 
entry. Generator functions return generators, which are iterators with 
extra behavior.

I would leave out For loop(2). The old pseudo-getitem iterator protocol 
is seldom explicitly used any more, in the say you showed.

In 'Even numbers', I have no idea what the complication of next_even() 
is about.

'Lazyness drawbacks' overflow_list is bizarre and useless.  overflow_gen 
is bizarre and buggy. If you are intentionally writing buggy code to 
make a point, label it as such on the slide.

Iterators just produce values. Generators can consume as well as produce 
values, which is why they can act as both iterators and coroutines.

Terry Jan Reedy

More information about the Python-list mailing list