#18758: Allow actions of a parent on itself
-------------------------------------+------------------------
Reporter: SimonKing | Owner:
Type: enhancement | Status: new
Priority: major | Milestone: sage-6.8
Component: coercion | Resolution:
Keywords: actions on itself | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: #18756 | Stopgaps:
-------------------------------------+------------------------
Comment (by SimonKing):
Replying to [comment:6 SimonKing]:
> Before I push my branch, I'll see what happens if I provide `Element`
with a default `__mul__` method that simply calls the coercion model. It
will of course make the first approach impossible, but I guess it would
speed-up the second (i.e., new) approach.
This is what happens:
{{{
sage: %timeit l*l
The slowest run took 6.49 times longer than the fastest. This could mean
that an intermediate result is being cached
100000 loops, best of 3: 7.71 µs per loop
sage: %timeit lM*lM
The slowest run took 5.82 times longer than the fastest. This could mean
that an intermediate result is being cached
100000 loops, best of 3: 7.91 µs per loop
sage: %timeit lR*lR
The slowest run took 4.27 times longer than the fastest. This could mean
that an intermediate result is being cached
100000 loops, best of 3: 7.03 µs per loop
}}}
In other words, using `Element` becomes faster when defining a ring
structure than `ModuleElement`. Probable reason: The default
`Element.__mul__` that I am suggesting will immediately use coercion,
whereas `ModuleElement.__mul__` first tries some shortcut that is not
available in my example.
Of course, `RingElement.__mul__` is still fastest, as it uses the right
shortcut.
Before pushing my branch, I plan to add tests and documentation. The
documentation will go to `sage.structure.element` and
`sage.structure.parent`. However, it is my experience that people using
`sage.combinat` have a tendency to work around coercion (see for example
`age.combinat.permutation.Permutation.__mul__`).
Can you suggest a place to put documentation on coercion so that it is
actually found by sage.combinat users?
--
Ticket URL: <http://trac.sagemath.org/ticket/18758#comment:8>
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.