#20246: Use `with strict_equality(True)` to work around hashing of p-adics
-------------------------------------+-------------------------------------
       Reporter:  saraedum           |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-7.2
      Component:  padics             |   Resolution:
       Keywords:  days71             |    Merged in:
        Authors:  Julian RĂ¼th        |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  
u/saraedum/use__with_strict_equality_true___to_work_around_hashing_of_p_adics|  
f4c5a9db729ccf911517039fdced282588210133
   Dependencies:  #16342, #16339     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Replying to [comment:29 saraedum]:
 > Replying to [comment:27 nbruin]:
 > > [strict_equality() does not work in weak dicts]
 > I thought that this is a common problem in sage and that is why we use
 `sage.misc.weak_dict` which uses equality by id to delete objects.

 Not quite. The problem that triggered writing the safer weakvaluedict was
 that equality testing on ''defunct objects in to process of being
 deleted'' is sometimes not supported anymore. This is because some objects
 depend on circular references to have their equality testing defined and
 we can't control the state of teardown present when the callback gets
 executed. It turned out that it was too much to ask that the key object
 under which the weakref is stored was still in a valid state during
 callback.

 Otherwise these objects have (or at least as supposed to have) well-
 defined equality tests during their lifetimes, and there is no particular
 reason to ban equality testing in callbacks.

 For p-adics, the equality testing would change with time during their
 useful lifetime. That means a new rule would come in place in sage: make
 sure your callback code does not depend on equality testing state between
 p-adics, because their equality-testing state is ill-defined.

 It would place a huge burden on callback writing: any callback would need
 to ensure to enforce the right equality testing regime around any place
 where it might be possible that p-adics get compared. For most callbacks
 it would be very hard to know this for certain, so basically any callback
 would need to have a `with strictequality(False):` around its body. And
 we'd still be unsafe in the face of threading (in a way we would never be
 able to fix later).

 So I think the scenario that lead to writing `weak_dict` is quite
 different from what we're facing here.

--
Ticket URL: <http://trac.sagemath.org/ticket/20246#comment:30>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to