[Python-ideas] Fwd: Extremely weird itertools.permutations
Tim Peters
tim.peters at gmail.com
Mon Oct 14 01:23:51 CEST 2013
[Tim]
>> 2. Making "equality" pluggable. Your later algorithm bought "find
>> equivalence classes" speed for hashable elements by using a dict, but
>> a dict's notion of equality can't be changed. So, make equality
>> pluggable, and that startup-time speed advantage vanishes for all but
>> operator.__eq__'s idea of equality.
[Oscar Benjamin]
> It sounds like you want Antoine's TransformDict:
> http://www.python.org/dev/peps/pep-0455/
Not really in this case - I want a two-argument function ("are A and B
equal?"). Not all plausible cases of that can be mapped to a
canonical hashable key. For example, consider permutations of a list
of lists, where the user doesn't want int and float elements of the
lists to be considered equal when they happen to have the same value.
Is that a stretch? Oh ya ;-)
More information about the Python-ideas
mailing list