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

Ticket #19016 – Description
v32 v33 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: 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 2 4 {{{ 3 5 sage: G = groups.presentation.Cyclic(4) … … 5 7 [1, a, a^2, a^2, a^3, a^1] 6 8 }}} 9 and symbolic expressions 10 {{{ 11 sage: f=sin(x)^2 12 sage: g=1cos(x)^2 13 sage: bool(f == g) 14 True 15 sage: hash(f) == hash(g) 16 False 17 }}} 18 and possibly many others 7 19 8 Nathann 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 9 41 10 42 [1] https://groups.google.com/d/topic/sagedevel/6rXKkF87Gtc/discussion