#11342: Make getattr faster on parents and elements
------------------------------+---------------------------------------------
Reporter: SimonKing | Owner:
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-4.7.2
Component: performance | Keywords: getattr parent element
Work_issues: | Upstream: N/A
Reviewer: Jeroen Demeyer | Author: Simon King
Merged: | Dependencies: #9944
------------------------------+---------------------------------------------
Comment(by SimonKing):
I just updated my last patch. It should be absolutely airtight, since it
is now explicitly tested whether the parent is None.
The timings, which is the main point of this ticket, are still fine. They
did almost not change compared with the old patches, but they are much
better than with unpatched sage-4.7.2.alpha2:
1. non-existing private attributes
{{{
sage: a = 1
sage: timeit('try: QQ.__bla\nexcept: pass')
625 loops, best of 3: 10.8 µs per loop
#unpatched: 15 µs per loop
sage: timeit('try: a.__bla\nexcept: pass')
625 loops, best of 3: 9.07 µs per loop
#unpatched: 13.9 µs per loop
sage: timeit('try: QQ.__bla_\nexcept: pass')
625 loops, best of 3: 14.3 µs per loop
#unpatched: 22.8 µs per loop
}}}
2. non-existing non-private attributes
{{{
sage: timeit('try: QQ.__bla_\nexcept: pass')
625 loops, best of 3: 14.2 µs per loop
#unpatched: 23 µs per loop
sage: timeit('try: a.__bla_\nexcept: pass')
625 loops, best of 3: 17.3 µs per loop
#unpatched: 23.2 µs per loop
sage: timeit('try: QQ.bla\nexcept: pass')
625 loops, best of 3: 13.9 µs per loop
#unpatched: 22.6 µs per loop
sage: timeit('try: a.bla\nexcept: pass')
625 loops, best of 3: 16.6 µs per loop
#unpatched: 25.9 µs per loop
}}}
3. existing attributes inherited from the category
{{{
sage: timeit('try: QQ.sum\nexcept: pass',number=10^5)
100000 loops, best of 3: 744 ns per loop
#unpatched: 754 ns per loop
sage: timeit('try: a.cartesian_product\nexcept: pass',number=10^5)
100000 loops, best of 3: 1.68 µs per loop
#unpatched: 3.97 µs per loop
}}}
I hope that the segfaults are finally gone!!
Apply trac11342-attribute_error_message.rebased.patch,
trac_11342_fix_pari_initialization.patch, trac_11342_fix_pari_ring.patch,
trac_11342_crypto_fixes.patch, trac11342_test_parent_on_getattr.patch
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11342#comment:56>
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.