generator/coroutine terminology
Rustom Mody
rustompmody at gmail.com
Mon Mar 16 10:19:29 EDT 2015
On Monday, March 16, 2015 at 7:10:03 PM UTC+5:30, Steven D'Aprano wrote:
> And of course, from a comp science theoretic perspective,
> generators are a kind of subroutine, not a kind of type.
You just showed Marko a few posts back, that
A generator is a special case of an iterator.
And you wrote the iterator with 'class'.
And from python 2.2(?) classes are types.
So I dont know what "comp science theoretic perspective" you are describing...
>From mine:
The generator
def gen():
yield 1
yield 2
is much closer to the list (ie data) [1,2]
than to say
def foo():
print 1
print 2
The only difference is that the list memoizes the data whereas the generator doesn't.
CLU perspective:
The iterator for a collection of complex_numbers can be used interchangeably with that for an array of integers
from https://en.wikipedia.org/wiki/CLU_%28programming_language%29
[Note: CLU-iterator ≡ python-generator]
Haskell perspective:
Lists are by default lazy and memoized.
IOW in Haskell: List ≡ Lazy list ≡ python generator + memoization
Scheme perspective:
Programmer can choose between normal and lazy lists.
Lazy lists are just normal lists + delay/force where
delay x ≡ lambda: x
force x ≡ x()
======================
Anyways...
Yes 15 years are past.
I dont expect the def can be revoked now.
[As far as I am concerned its a minor wart]
But the mess around the docs can certainly be cleaned up.
More information about the Python-list
mailing list