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 terry.reedy
Recipients Sumudu.Fernando, eric.araujo, falsetru, rhettinger, terry.reedy
Date 2012-01-19.03:44:25
SpamBayes Score 0.0019738493
Marked as misclassified No
Message-id <1326944666.43.0.932824448111.issue10109@psf.upfronthosting.co.za>
In-reply-to
Content
A relatively simple change would be to allow the first iterable to be 'infinite', when repeat==1, by not calling tuple() on it. The reason for turning the iterables into concrete sequences is because they might not be reiterable. (cycle() does the same for the same reason.) But since the first iterable is only iterated once, this does not apply to it.

    if repeat == 1:
        pools = [args[0:1]].extend(tuple(pool) for pool in args[1:])
    else:
        pools = [tuple(pool) for pool in args] * repeat

The counter argument to this or any generalized proposal is that one can expand the product() into enough loops to avoid infinite (or very large) args. For example, the following produces '1AA', '1AB', ..., '1EE', '2AA', ... indefinitely.

naa=(''.join((str(n),)+s) for n in itertools.count(1)
     for s in itertools.product(string.ascii_uppercase[0:5], repeat=2))

RAYMOND: Do you think the doc should specify that each iterable must be finite, and that explicit loops are the alternative if not?
History
Date User Action Args
2012-01-19 03:44:26terry.reedysetrecipients: + terry.reedy, rhettinger, falsetru, eric.araujo, Sumudu.Fernando
2012-01-19 03:44:26terry.reedysetmessageid: <1326944666.43.0.932824448111.issue10109@psf.upfronthosting.co.za>
2012-01-19 03:44:25terry.reedylinkissue10109 messages
2012-01-19 03:44:25terry.reedycreate