#20686: Optimize method lookup from the categories for instances of Cython 
classes
---------------------------+----------------------------
   Reporter:  nthiery      |            Owner:
       Type:  enhancement  |           Status:  new
   Priority:  major        |        Milestone:  sage-7.3
  Component:  categories   |         Keywords:
  Merged in:               |          Authors:
  Reviewers:               |  Report Upstream:  N/A
Work issues:               |           Branch:
     Commit:               |     Dependencies:
   Stopgaps:               |
---------------------------+----------------------------
 For instances of Cython classes, the inheritance from categories is
 emulated by a manual lookup in
 `sage.structure.element.Element.__getattr__`. This lookup is about 10
 times slower than a normal method lookup::

 {{{
 sage: def foo(self): return
 sage: Sets().element_class.foo = foo

 sage: def g(x):
 ....:     for i in range(1000):
 ....:          x.foo()

 sage: x = Semigroups().example().an_element()
 sage: %timeit g(x)
 10000 loops, best of 3: 115 µs per loop

 sage: x = 1
 sage: %timeit g(x)
 1000 loops, best of 3: 1.18 ms per loop
 }}}

 So there should be room for optimization (or using a different
 approach for emulating this inheritance).

 First step: profiling ...

--
Ticket URL: <http://trac.sagemath.org/ticket/20686>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to