[Python-ideas] Fwd: Extremely weird itertools.permutations

MRAB python at mrabarnett.plus.com
Sun Oct 13 21:30:42 CEST 2013


On 13/10/2013 20:02, Tim Peters wrote:
> [MRAB, posts a beautiful solution]
>
> I don't really have a use for this, but it was a lovely programming
> puzzle, so I'll include an elaborate elaboration of MRAB's algorithm
> below.  And that's the end of my interest in this ;-)
>
> It doesn't require that elements be orderable or even hashable.  It
> does require that they can be compared for equality, but it's pretty
> clear that if we _do_ include something like this, "equality" has to
> be pluggable.  By default, this uses `operator.__eq__`, but any
> 2-argument function can be used.  E.g., use `operator.is_` to make it
> believe that only identical objects are equal.  Or pass a lambda to
> distinguish by type too (e.g., if you don't want 3 and 3.0 to be
> considered equal).  Etc.
>
[snip]
I posted yet another implementation after that one.



More information about the Python-ideas mailing list