#19016: Better hash for Element
-------------------------------------+-------------------------------------
Reporter: ncohen | Owner:
Type: defect | Status: needs_work
Priority: blocker | Milestone: sage-6.9
Component: misc | Resolution:
Keywords: | Merged in:
Authors: Nils Bruin, | Reviewers:
Vincent Delecroix | Work issues:
Report Upstream: N/A | Commit:
Branch: public/19016 | 83a758f5c9e19daa0e60914a633ded84d75da4e0
Dependencies: #18246 | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by nbruin):
Replying to [comment:45 vdelecroix]:
> I am not sure I do like your changes to the unit tests in categories.
The zero/one values are cached most of the time. If it was to be mutable
then a Sage user might end up with a wrong unit.
I don't think we have another option:
- testing if something is hashable doesn't test if something is mutable
- something that is immutable can be unhashable. Elements in monoids with
an unsolved wordproblem are/should be examples of that
- python guidelines ''say'' that mutable elements should not be hashable,
but this is not enforced.
- python simply doesn't provide a sure-fire way of testing if something
is mutable.
- Note that even for properly hashable elements the internal data
structure can still change (attributes, internal representation), as long
as equality holds. But for reuse of elements those other attributes can
still be important! So even hashability does not imply an element is safe
for caching/reuse.
Feel free to extend the tests I've proposed. However, assuming 0 and 1 are
hashable is not a good test for the stated goal.
--
Ticket URL: <http://trac.sagemath.org/ticket/19016#comment:50>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.