#12808: Optimize ClassCallMetaClass using Cython
--------------------------------------------------+-------------------------
Reporter: hivert | Owner: jason
Type: enhancement | Status: new
Priority: major | Milestone: sage-5.0
Component: misc | Resolution:
Keywords: classcall UniqueRepresentation | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Florent Hivert | Merged in:
Dependencies: | Stopgaps:
--------------------------------------------------+-------------------------
Comment (by hivert):
I'm finishing the patch, I've added a large optimization for the other
branch
where there is no {{{__classcall__}}}
Here are the results in the basis case (no {{{__classcall__}}})::
{{{
sage: class Rien(object):
... pass
sage: from sage.misc.classcall_metaclass import ClasscallMetaclass
sage: class NOCALL(object):
... __metaclass__ = ClasscallMetaclass
... pass
Standard Python class:
sage: %timeit [Rien() for i in range(10000)]
125 loops, best of 3: 1.7 ms per loop
Currently:
sage: %timeit [NOCALL() for i in range(10000)]
25 loops, best of 3: 15.9 ms per loop
Cython version:
sage: %timeit [NOCALL() for i in range(10000)]
125 loops, best of 3: 3.59 ms per loop
Cython optimized version:
sage: %timeit [NOCALL() for i in range(10000)]
125 loops, best of 3: 1.76 ms per loop
}}}
So I'm 5% only slower than normal class.
Here are the results in the basis case (no {{{__classcall__}}})::
{{{
sage: class CALL(object):
... __metaclass__ = ClasscallMetaclass
... @staticmethod
... def __classcall_private__(cls, arg):
... arg = arg + arg
... return arg
Currently:
sage: %timeit [CALL(i) for i in range(10000)]
25 loops, best of 3: 8.7 ms per loop
Cython version:
sage: %timeit [CALL(i) for i in range(10000)]
125 loops, best of 3: 4.33 ms per loop
Cython optimized version (no mesurable difference from the preceding):
sage: %timeit [CALL(i) for i in range(10000)]
125 loops, best of 3: 4.34 ms per loop
}}}
Here I'm twice as fast as before.
I'm cleanup the patch (doctests) an will post it shortly.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12808#comment:2>
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.