This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yegle
Recipients Sumudu.Fernando, eric.araujo, falsetru, rhettinger, terry.reedy, yegle
Date 2014-10-02.03:08:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1412219282.67.0.95935303068.issue10109@psf.upfronthosting.co.za>
In-reply-to
Content
Found another example that shows horrible performance when using itertools.product:

def gen():
  l = [itertools.permutations(range(10)) for _ in range(10)]
  g = itertools.product(*l)
  for i in g:
    yield i

A simple next() to this generator takes 16 seconds on my desktop.

I use this recursive product() instead and the performance is acceptable:

def product(*args):
    if len(args) == 1:
        for i in args[0]:
            yield [i]
    else:
        for i in args[0]:
            for j in product(*args[1:]):
                j.append(i)
                yield j
History
Date User Action Args
2014-10-02 03:08:02yeglesetrecipients: + yegle, rhettinger, terry.reedy, falsetru, eric.araujo, Sumudu.Fernando
2014-10-02 03:08:02yeglesetmessageid: <1412219282.67.0.95935303068.issue10109@psf.upfronthosting.co.za>
2014-10-02 03:08:02yeglelinkissue10109 messages
2014-10-02 03:08:02yeglecreate