[issue39755] Change example of itertools.product

2020-02-25 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for the suggestion, but I will decline.  The existing wording 
communicates the intended mental relationship between the product() and nested 
for-loop.  IMO, the proposed change obfuscates that main point.  

The details of how product works are communicated in the pure python equivalent 
block that follows.  That code clearly shows that each pool is first converted 
to a tuple.  So, your point about infinite iterators is already covered and 
doesn't need to be said twice.

We could replace "the same as" with "roughly the same as", but I don't really 
think that would be an improvement.

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39755] Change example of itertools.product

2020-02-25 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39755] Change example of itertools.product

2020-02-25 Thread Mark Bell


New submission from Mark Bell :

The documentation for itertools.product at: 
https://docs.python.org/3/library/itertools.html#itertools.product
currently says that:

For example, product(A, B) returns the same as ((x,y) for x in A for y in B)

While this is broadly correct, since product first converts its arguments to 
tuples, this is not true if A or B are infinite iterables. For example, when A 
= itertools.count() and B = range(2) then the former runs forever using 
infinite memory, whereas the latter returns the lazy generator immediately for 
use.

Would it be clearer / more correct to instead say:

For example, product(A, B) returns the same as ((x,y) for x in tuple(A) for 
y in tuple(B))

--
assignee: docs@python
components: Documentation
messages: 362672
nosy: Mark.Bell, docs@python
priority: normal
severity: normal
status: open
title: Change example of itertools.product
versions: Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com