Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65246

Re: generator slides review

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'explicitly': 0.05; 'generators': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'url:github': 0.09; 'jan': 0.12; 'buggy': 0.16; 'comments:': 0.16; 'defined.': 0.16; 'entry.': 0.16; 'evaluates': 0.16; 'iterator': 0.16; 'iterators': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:generator': 0.16; 'url:py': 0.16; 'url:talks': 0.16; 'wrote:': 0.18; 'later': 0.20; 'saying': 0.22; 'header:User- Agent:1': 0.23; '(or': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'point': 0.28; 'leave': 0.29; 'am,': 0.29; 'url:code': 0.29; 'label': 0.30; 'skip:g 30': 0.30; "i'm": 0.30; 'code': 0.31; 'about.': 0.31; 'assert': 0.31; 'values.': 0.31; 'anyone': 0.31; "i'd": 0.34; 'something': 0.35; 'definition': 0.35; 'more,': 0.35; 'wrong': 0.37; 'feedback': 0.38; 'to:addr:python-list': 0.38; 'bad': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'expression': 0.60; 'url:u': 0.61; 'received:173': 0.61; 'first': 0.61; 'act': 0.63; 'url:index': 0.63; 'hear': 0.63; 'such': 0.63; 'different': 0.65; 'love': 0.65; 'here': 0.66; 'chinese': 0.74; '(better': 0.84; 'andrea': 0.84; 'received:fios.verizon.net': 0.84; 'seldom': 0.84; 'url:master': 0.84; 'tomorrow': 0.95
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: generator slides review
Date Sat, 01 Feb 2014 20:08:16 -0500
References <CAF_E5JYWZXkq98ri63BMQst3kpPVhO1K5xQbQ0ZHCuRTYZXvUA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-173-75-254-207.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To <CAF_E5JYWZXkq98ri63BMQst3kpPVhO1K5xQbQ0ZHCuRTYZXvUA@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6294.1391303316.18130.python-list@python.org> (permalink)
Lines 46
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391303316 news.xs4all.nl 2896 [2001:888:2000:d::a6]:55634
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65246

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: generator slides review Terry Reedy <tjreedy@udel.edu> - 2014-02-01 20:08 -0500

csiph-web