[Python-ideas] Implement `itertools.permutations.__getitem__` and `itertools.permutations.index`

Paul Moore p.f.moore at gmail.com
Tue May 6 17:49:36 CEST 2014


On 6 May 2014 16:40, Tal Einat <taleinat at gmail.com> wrote:
> The real question IMO is if this is useful enough to bother including
> in the stdlib. For example, I don't think it would pass the "potential
> uses in the stdlib" test. Perhaps Ram (the OP) has some actual
> use-cases for this?

Agreed, I suspect this is more appropriate as a utility on PyPI. But I
stand by my statement that wherever it's implemented, it should *not*
be spelled permutations(x)[N], as having indexing with a small index
being significantly slower than a few calls to next() is a nasty
performance trap for the unwary (no matter how rare it will be in
practice).

Paul


More information about the Python-ideas mailing list