#13378: Do not cache the non-existence of coerce/convert map too often, and do 
not
pretend that there is a conversion where it doesn't make sense at all
----------------------------------------------------+-----------------------
       Reporter:  SimonKing                         |         Owner:  robertwb
           Type:  defect                            |        Status:  new     
       Priority:  major                             |     Milestone:  sage-5.3
      Component:  coercion                          |    Resolution:          
       Keywords:  coercion conversion object cache  |   Work issues:          
Report Upstream:  N/A                               |     Reviewers:          
        Authors:                                    |     Merged in:          
   Dependencies:                                    |      Stopgaps:          
----------------------------------------------------+-----------------------
Description changed by SimonKing:

Old description:

> Sorry for the long ticket title.
>
> About the first part of the title:
> {{{
> sage: P.<x,y> = QQ[]
> sage: P.is_coercion_cached(x)
> False
> sage: P.coerce_map_from(x)
> sage: P.is_coercion_cached(x)
> True
> }}}
> Hence, there is a reference to x in the coercion cache for P. OK, by #715
> and friends, the reference is weak --- unless x does not allow weak
> references, in which case the reference will be strong, and x would not
> be collectable. Hence, a potential memory leak.
>
> About the second part:
> {{{
> sage: ZZ.convert_map_from(1)
> Conversion map:
>   From: Set of Python objects of
>   To:   Integer Ring
> }}}
> or
> {{{
> sage: P.convert_map_from(x)
> Traceback (most recent call last):
> ...
> TypeError: Cannot convert
> sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular
> to sage.structure.parent.Parent
> }}}
> In both cases, I believe the answer should be "None".

New description:

 Sorry for the long ticket title.

 About the first part of the title:
 {{{
 sage: P.<x,y> = QQ[]
 sage: P.is_coercion_cached(x)
 False
 sage: P.coerce_map_from(x)
 sage: P.is_coercion_cached(x)
 True
 }}}
 Hence, there is a reference to x in the coercion cache for P. OK, by #715
 and friends, the reference is weak --- unless x does not allow weak
 references, in which case the reference will be strong, and x would not be
 collectable. Hence, a potential memory leak.

 About the second part:
 {{{
 sage: ZZ.convert_map_from(1)
 Conversion map:
   From: Set of Python objects of
   To:   Integer Ring
 }}}
 or
 {{{
 sage: P.convert_map_from(x)
 Traceback (most recent call last):
 ...
 TypeError: Cannot convert
 sage.rings.polynomial.multi_polynomial_libsingular.MPolynomial_libsingular
 to sage.structure.parent.Parent
 }}}

 I think it is not good that the error occurs. The answer of
 `ZZ.convert_map_from(1)` seems strange, but apparently those things
 actually occur, namely conversions from the category of sequences.

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13378#comment:1>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to