[issue40230] Itertools.product() Out of Memory Errors
Tim Peters
report at bugs.python.org
Fri Apr 10 00:51:44 EDT 2020
Tim Peters <tim at python.org> added the comment:
Henry, I have to ask again: please give at least one specific, concrete example of the behavior you're objecting to. English isn't helping, and I still have no idea what your complaint is.
What I'm looking for:
for i in itertools.product(???):
pass
where you replace the ??? with executable code (preferably not using numpy or any other extension package) that provokes the MemoryError you're talking about.
For example, here I'm constructing a case with a million arguments. There's no problem at all:
>>> import itertools
>>> args = [range(100) for i in range(1_000_000)]
>>> for i in itertools.product(*args):
... print(len(i))
[and it prints 1000000 over & over until I get bored and kill it]
Note if it _did_ provoke a problem, we probably wouldn't care - there are no plausible realistic use cases for passing a million arguments to product().
You haven't given us a way to reproduce your complaint, or even a clue as to the number of arguments you're talking about. The above code was my best guess as to what you _might_ be talking about. But since there's no MemoryError in sight, apparently not.
I'm suspecting this may be an XY problem[1], and especially because you posted "a solution" instead of an actual problem ;-)
[1] https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40230>
_______________________________________
More information about the Python-bugs-list
mailing list