New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better hash for Element #19016
Comments
Branch: u/ncohen/19016 |
This comment has been minimized.
This comment has been minimized.
Commit: |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:3
Hi Nathann, What about #18246? Just returning Vincent |
comment:4
If you see a way to turn #18246 into a What about a middle ground: raise a warning, which would appear only once, whenever this 0 hash function is used? This is a very bad bug and it needs to be fixed. Creating tickets that we forget is nto much more responsible than doing nothing. Nathann |
comment:5
By the way, it is not even the same hash function. Here it is |
comment:6
Replying to @nathanncohen:
Putting in
It is already a bit better.
It is.
I did not forget as you see ;-) With your implementation, I am pretty sure that the running time of the tests will be much slower. Sage very often put elements in dictionaries or sets. Your solution does not help users to see that |
comment:7
Remember that #18246 is not even about the hash function that I change here.
If you think that we can fix the bug quickly by removing the Concerns about efficiency do not weight much compares to wrong results. Nathann |
comment:8
-1 to a constant hash. That leads to such bad performance that it amounts to "wrong results". +1 to removing silly default hashes. Hashing is simply not something that can be done on a very general level. For your example, unless you come up with a canonical form for group elements that you can take the hash of, you really shouldn't have a hash function, by the way. These elements should be unhashable, not hashable with a constant hash value. |
comment:9
#18246 needs review (it removes the |
comment:10
What is your position for "constant hash" Vs "we change nothing and the bug stays"? How many classes do you think would be broken (and would have to be fixed) if this hash is removed? Are you willing to help? Nathann |
comment:11
Replying to @nathanncohen:
"Change nothing". I think it's unfortunate that hashing by repr will usually work quite well in cases where a hash is possible: a hash usually requires a canonical form to compute the hash from and that canonical form will usually be used for printing, because that's nice. So in practice, the default hash (although much too slow to be a reasonable hash) will probably work when it should. In cases where the current default hash doesn't work, I think that having it as it is now will lead to better detection than when we change it to a default hash of 0. When people find this in particular cases, the solution is clear: actively disable the hash. Having to disable something is of course the wrong way around: the default hash shouldn't be there in the first place. But putting a constant 0 hash there instead doesn't make transitioning to the desired situation any easier. |
comment:12
I love those guys. "You fix a bug, but because it is not done the way I like I will block your tickets, and the bug will stay unsolved. And no, I will not help do it the way I want to see it done. You have to do it by yourself, while I watch you sweat". Free software. See, I wouldn't feel well with myself if after something like that I got to work and started implementing what you ask me to. So the bug will stay, thanks to you. Today, you contributed to the common effort for a better mathematical software. Nathann |
comment:13
As I said in [comment:9] I did remove the stupid I guess that the same strategy would also be good for |
comment:14
I do not intend to touch this ticket again. I'm starting a new trend: when people tell me that my idea is bad, I stop fighting and leave (see #18904, though it's not the first). So that if I ever find something more interesting to do during my holidays than contribute to Sage, I won't hesitate to delete my account and move on to other things. Nathann |
comment:15
The default |
comment:16
Replying to @vbraun:
That might be an easy move since we would just have to change the category to something like But in the long run, do we really want to use only once the string representation for the hash? Is that how we want the user to implement their own |
comment:18
Often you can have normal forms on general grounds, so IMHO would be reasonable to just make |
comment:113
Hi Volker, Thanks for having a look. On which Sage version are you testing!? If this is not merged early in a beta we have few chances to let it pass! The doctest you mentioned are introduced by a ticket on asymptotic expansions not previously merged in sage.6.10.beta1. I am willing to merge the associated branch in this ticket but you must ensure me that I will not have to do it thousands time. Vincent |
comment:114
How about you try to reproduce it with said ticket, if you can get a new branch by tomorrow I can merge it. Can you also fix the random failure at #19488 |
Branch pushed to git repo; I updated commit sha1. Last 10 new commits:
|
comment:116
Replying to @vbraun:
The doctest gets introduced on this ticket and it's a bad one: it's just comparing the parents, so the result is fundamentally ill-defined. Just delete the test (or check that it's not an error if you care about that behaviour. I'd say |
comment:117
Replying to @nbruin:
I agree with Nils that an error would be more appropriate. Though, for the sake of that ticket I would be inclined to follow the default comparison code from |
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:119
Actually, for the sake of this ticket I think that we should not change anything to the previous behavior of New commits:
|
Changed branch from public/19016-bis to |
Changed commit from |
comment:121
(applause for what was done here) |
comment:122
Thanks Volker! |
As reported on sage-devel [1],
Element
implements its hash based on its string representation. This causes a lot of troublesequality => same hash
assumption for finitely presented groupsand symbolic expressions
and possibly many others
rename
feature (see also Rename change the hash value of some objects #8119)and similarly, hashing should not be available on any mutable object.
There are several possibilities that are currently being discussed:
0
by default (original proposition of the ticket)TypeError
by default (as it the case forSageObject
, see remove naive __hash__ from SageObject #18246)[1] https://groups.google.com/d/topic/sage-devel/6rXKkF87Gtc/discussion
See also: #19302, #19321, #19331
Component: misc
Author: Nils Bruin, Vincent Delecroix
Branch:
c7b4f0e
Reviewer: Volker Braun
Issue created by migration from https://trac.sagemath.org/ticket/19016
The text was updated successfully, but these errors were encountered: