Ticket #10130 (new enhancement)
Revamp __hash__, __cmp__ and __richcmp__
|Reported by:||roed||Owned by:||robertwb|
|Cc:||robertwb, nthiery||Work issues:|
There are a number of confusing and non-optimal features of the way Sage currently handles hashing and comparison.
- Because of Python, if you're writing a Cython class and you override one of these functions, you must redefine the others as well. This is easy to forget and confuses new users.
- The comparison infrastructure in sage.structure.element predates cpdef, and could be made far less confusing with cpdef.
- hashes of parents are used extensively in the coercion framework, so speed is quite important. But since parents are usually written in Python, the current model will always have at least a dictionary lookup (for example, in finding a cached self.__hash). And often parents don't override the default hashing code and they fall back to slow __repr__ methods.
Note: See TracTickets for help on using tickets.