sage: Set([[(Integer(0), Integer(0)), (Integer(1), Integer(1))],[(Integer(0), Integer(0)), (Integer(1), Integer(1))]]).cardinality()
2
- the problem is that lists are not hashable, and considered unequal.
The problem is that in general testing objects for equality is far
from obvious, might be algorithmically unsolvable, etc.
- the problem is that lists are not hashable, and considered unequal.
The problem is that in general testing objects for equality is far
from obvious, might be algorithmically unsolvable, etc.
Why is Set trying then? I can see in the documentation that "Sets with unhashable objects work, but with less functionality", but as this example shows, it's more "but with misleading functionality". How is this ever useful?
sage: a,b=list(Set([[0],[0]]))
sage: a==b
TrueI don't know if this is ever useful internally (I doubt it; I expect it mainly makes bugs harder to find), but we should definitely not be exposing this as user interface, Python's own "frozenset" and "set" are better behaved.