#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:
----------------------------------------------------+-----------------------
Comment (by SimonKing):
Replying to [comment:2 nbruin]:
> Are you sure
> {{{
> ZZ.convert_map_from(10)
> }}}
> should not raise an error?
No, I am not sure.
> Shouldn't the argument be a parent?
Or a type, because we want a coercion (not just a conversion) between
Python ints and Sage integers.
> This has the potential for getting hairy if you want this to work:
> {{{
> sage: A=AdditiveGroups()
> sage: A(ZZ)
> Free commutative group on generators [1]
> }}}
That's totally separate. `AdditiveGroups()`, which doesn't exist yet, is a
category and not a parent. It would be desirable, though, to have
{{{
sage: ZZ.category() # current behaviour
Category of euclidean domains
sage: AdditiveGroups()(ZZ).category() # not implemented
Category of additive groups
}}}
> because then `parent(ZZ)`
ZZ has no parent, it ''is'' a parent. Elements have a parent, but parents
have a category.
> It actually makes me wonder if parent(ZZ) should even work.
parent(X) currently returns the type of X, if X has no method
`X.parent()`. This is in order to make `int(1)+1` work. I don't think one
should slow it down by distinguishing cases like "if X is a parent then
parent(X) should raise an error, but if X is anything else then either
return X.parent() or type(X)".
Anyway. I tried to introduce a shortcut for `Parent.coerce_map_from`, such
that `None` is returned (without caching) if the argument is neither a
`CategoryObject` nor a type. Similarly, I introduced a shortcut for
`Parent.convert_map_from`, but had to be more relaxed, because apparently
convert maps also need to exist from sequences (which are `SageObject`,
but not `CategoryObject`).
Result: It nearly worked. There was one segfault in
sage.rings.polynomial.infinite_polynomial_element (which I wrote) and one
doctest error.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13378#comment:3>
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.