generator slides review

Terry Reedy tjreedy at udel.edu
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):
> https://dl.dropboxusercontent.com/u/3183120/talks/generators/index.html#3
>
> and the code I'm using is:
> https://github.com/AndreaCrotti/generators/blob/master/code/generators.py
> and the tests:
> https://github.com/AndreaCrotti/generators/blob/master/code/test_generators.py
>
> 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).

Comments:

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

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.

@monocle
-- 
Terry Jan Reedy




More information about the Python-list mailing list