Changes between Version 31 and Version 32 of Ticket #19016
 Timestamp:
 08/15/15 19:11:23 (5 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Ticket #19016

Property
Milestone
changed from
sage6.9
tosageduplicate/invalid/wontfix

Property
Milestone
changed from

Ticket #19016 – Description
v31 v32 1 As reported on sagedevel [1], the default hash function implemented in `Element` (as `return hash(str(self)))`) causes a lot of troubles 2 3  it breaks the {{{equality => same hash}}} assumption for finitely presented groups 1 As reported on sagedevel [1], the default hash function implemented in `Element` makes it very likely that `hash` and `==` will not agree. With this branch, the hash is constant and set to 0, making it less likely. Incidentally, it fixes the following bug: 4 2 {{{ 5 3 sage: G = groups.presentation.Cyclic(4) … … 7 5 [1, a, a^2, a^2, a^3, a^1] 8 6 }}} 9 and symbolic expressions10 {{{11 sage: f=sin(x)^212 sage: g=1cos(x)^213 sage: bool(f == g)14 True15 sage: hash(f) == hash(g)16 False17 }}}18 and possibly many others19 7 20  it is highly incompatible with the `rename` feature (see also #8119) 21 {{{ 22 sage: from sage.structure.element import Element 23 sage: class E(Element): 24 ....: def __init__(self): 25 ....: Element.__init__(self, Parent()) 26 sage: e = E() 27 sage: hash(e) 28 4965357552728411610 29 sage: e.rename('hey') 30 sage: hash(e) 31 6429308858210906323 32 }}} 33 and similarly, hashing should not be available on any mutable object. 34 35  it might be very bad for performance: see #18215 and #18239 for examples 36 37 There are several possibilities that are currently being discussed: 38  make it return `0` by default (original proposition of the ticket) 39  make it raise a `TypeError` by default (as it the case for `SageObject`, see #18246) 40  let it as it is but raise a Warning 8 Nathann 41 9 42 10 [1] https://groups.google.com/d/topic/sagedevel/6rXKkF87Gtc/discussion