#14711: Weak references in the coercion graph
-------------------------------------+-------------------------------------
       Reporter:  jpflori            |        Owner:  davidloeffler
           Type:  defect             |       Status:  needs_review
       Priority:  critical           |    Milestone:  sage-6.2
      Component:  number fields      |   Resolution:
       Keywords:  memleak, number    |    Merged in:
  field, QuadraticField              |    Reviewers:  Nils Bruin, Jean-
        Authors:  Simon King,        |  Pierre Flori
  Travis Scrimshaw, Jean-Pierre      |  Work issues:
  Flori                              |       Commit:
Report Upstream:  N/A                |  ea58b22f0bf2652e7d04b3d55e6217dcb8732cdf
         Branch:                     |     Stopgaps:
  public/ticket/14711                |
   Dependencies:                     |
-------------------------------------+-------------------------------------

Comment (by nbruin):

 Replying to [comment:244 tscrim]:
 > Eeek, you're right. However I believe we should not print the warning
 message when we're not exposing an object to the public.

 Then you should probably just chop off the warning from the string, since
 that seems by far the cheapest option (other than coming up with an
 entirely new protocol):

 {{{
 sage: def fn(S):
     i=S.find('\n\n        WARNING')
     return S[:i] if i >=0 else S
 sage: phi=QQ._internal_coerce_map_from(ZZ)
 sage: timeit("str(phi)")
 625 loops, best of 3: 15.7 µs per loop
 sage: timeit("fn(str(phi))")
 625 loops, best of 3: 16.9 µs per loop
 sage: timeit("str(copy(phi))")
 625 loops, best of 3: 23.6 µs per loop
 }}}
 And to check the penalty on a normal, strong, map:
 {{{
 sage: psi=copy(phi)
 sage: timeit("str(psi)")
 625 loops, best of 3: 9.97 µs per loop
 sage: timeit("fn(str(psi))")
 625 loops, best of 3: 11.4 µs per loop
 }}}

 Whether you do it lazily or upon creation of the error message is another
 matter, but I think this example shows that just stripping the "WARNING"
 from the string when that is absolutely required is cheap enough compared
 to producing the string in the first place. I do think it will be a source
 for confusion if we start printing objects in error messages differently
 from how they are normally represented.

 Would the following string rep perhaps be more acceptable?
 {{{
 sage: phi
 (internal coercion system map--copy before use) Natural morphism:
   From: Integer Ring
   To:   Rational Field
 }}}

 > Another option would be to print the warning message via `_repr_help`
 that Volker proposed in #15036 comment 20 for the internal maps. How do
 you feel about this?

 I think that's bad, because Volker's proposal serves a completely
 different purpose. This has nothing to do with something being printed at
 top-level or not, but with the context in which it is printed.

--
Ticket URL: <http://trac.sagemath.org/ticket/14711#comment:245>
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/d/optout.

Reply via email to