#14711: Memleak when creating QuadraticField
-------------------------------------------------+-------------------------
       Reporter:  jpflori                        |        Owner:
           Type:  defect                         |  davidloeffler
       Priority:  critical                       |       Status:  new
      Component:  number fields                  |    Milestone:  sage-5.12
       Keywords:  memleak, number field,         |   Resolution:
  QuadraticField                                 |    Merged in:
        Authors:                                 |    Reviewers:
Report Upstream:  N/A                            |  Work issues:
         Branch:  u/SimonKing/ticket/14711       |       Commit:
   Dependencies:                                 |     Stopgaps:
-------------------------------------------------+-------------------------

Comment (by nbruin):

 Replying to [comment:54 SimonKing]:

 > I think the (unwritten, I am afraid) contract is that
 `register_coercion()` is only called in `__init__`. So, perhaps it should
 rather be `_register_coercion()`, to remove it from the user interface.

 Absolutely not! I think it's a very important feature that coercions can
 be discovered "lazily", i.e., be registered after the fact. It also means
 (but this is just a fact of life) that, while parents are supposed to be
 immutable, their relations in the (global state)! coercion graph can
 evolve over time.
 You could of course have a `_register_coercion` for internal use that
 mandates being passed a map with the promise no-one else will keep a
 reference to that map, but I'm pretty sure we have to keep an advertised
 `register_coercion`. You could ask sage-devel, of course.

 At some point there was even an idea to have a context manager to
 temporarily modify the coercion graph:
 {{{
 K=QuadraticField(3)
 with coercion(K.real_embeddings()[0]):
     print 1+K.0
 }}}
 leading to `-0.732050807568877` (assuming the first embedding is the
 negative one).
 For basic computations these things are not so essential, but by the time
 you're a couple levels deep, e.g., you want to compute the archimedean
 period matrices of some abelian variety defined over a number field,
 letting the coercion framework to the required conversions might be the
 only quick way to actually get your data in the right ring. I think we
 don't want to take away that possibility.

--
Ticket URL: <http://trac.sagemath.org/ticket/14711#comment:55>
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/groups/opt_out.

Reply via email to