[issue40806] itertools.product not lazy

2020-05-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset e4cc3a7c1f5ba9ea2c3015a5bf09cb5b93db5d47 by Miss Islington (bot) 
in branch '3.9':
bpo-40806: itertools.product immediately consumes its inputs (GH-20492) 
(GH-20498)
https://github.com/python/cpython/commit/e4cc3a7c1f5ba9ea2c3015a5bf09cb5b93db5d47


--

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Updated the docs to note that inputs are fully consumed before the iterator is 
run.

FYI, notes on infinite iterable inputs likely belong the FAQs because they 
aren't specific to product().  Similar effects would be seen with list(x(1)), 
sorted(x(1)), set(x(1)), tuple(x(1)), etc.

--
resolution:  -> fixed
stage: patch review -> 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



[issue40806] itertools.product not lazy

2020-05-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset cfc6ce4d40f2f01314b7e283fb972a7bb3ed3faa by Ramil Nugmanov in 
branch 'master':
bpo-40806: Clarify that itertools.product immediately consumes its inpt 
(GH-20492)
https://github.com/python/cpython/commit/cfc6ce4d40f2f01314b7e283fb972a7bb3ed3faa


--

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +19747
pull_request: https://github.com/python/cpython/pull/20498

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread Ramil Nugmanov


Change by Ramil Nugmanov :


--
keywords: +patch
pull_requests: +19741
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/20492

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

Hi Ramil, itertools.product() expect its argument to be finite iterables, it 
needs to keep all their elements in memory anyway at it "cycles around" to 
produce all possible pairs.

Basically, product(x(1), x(2)) is equivalent to product(tuple(x(1)), 
tuple(x(2))).


I see that the documentation does not mention that the arguments must be 
finite, could you open a PR to improve it?

--
nosy: +remi.lapeyre

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
nosy: +rhettinger, tim.peters

___
Python tracker 

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



[issue40806] itertools.product not lazy

2020-05-28 Thread Ramil Nugmanov


New submission from Ramil Nugmanov :

def x(y):
while True:
yield y

p = product(x(1), x(2))

next(p)  # this string will never be reached.

--
components: Library (Lib)
messages: 370201
nosy: nougmanoff
priority: normal
severity: normal
status: open
title: itertools.product not lazy
type: behavior
versions: Python 3.8

___
Python tracker 

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