#12601: @cached_method does not work for special methods
-------------------------------------------------+-------------------------
Reporter: saraedum | Owner: jason
Type: enhancement | Status:
Priority: minor | needs_review
Component: misc | Milestone: sage-5.12
Keywords: cached_method, cache, | Resolution:
operator, special method | Merged in:
Authors: Simon King | Reviewers:
Report Upstream: Completely fixed; Fix | Work issues:
reported upstream | Commit:
Branch: | Stopgaps:
Dependencies: #15038 |
-------------------------------------------------+-------------------------
Comment (by nbruin):
Replying to [comment:10 SimonKing]:
> PS: One thing I worry about is the startup time. After all, for each
cached method, it is now needed to decide whether the function name starts
and ends with two underscores.
If that's a problem, why not just leave them separate decorators? By the
time someone is decorating a special method, they probably are doing the
wrong thing or they really know what they're doing. Plus, not all `__*__`
are special method, are they? Since the list of special methods is short
and discrete, I think you should match on the whole name. Perhaps the list
is available in the python library somewhere.
Incidentally, I suspect that this will not work for cdef classes at all,
due to the special way in which special methods get compiled (and the fact
they end up in slots)
By the way, have you done timings on `ArgumentFixer` overhead? Calling a
cached function with arguments has considerable overhead (easily 4 times
as expensive). As a result, instantiating a `CachedRepresentation` no-op
class with `__init__` arguments is much more expensive than instantiating
the corresponding normal no-op class. I think this can really affect
things like creating matrices from a list of arguments (the default way!)
because the parent, the matrix algebra, must get created.
`ArgumentFixer` can definitely be improved: several lists there get
intensively rewritten and some methods get looked up where straight
`PyList_...` python library calls could get used. I'm not sure to what
extent that would improve the situation and how much we lose to this
overhead in practice, but it's definitely a possible source:
`ArgumentFixer` is not definitely not without cost and it gets used for
any cached method/function call that has arguments.
--
Ticket URL: <http://trac.sagemath.org/ticket/12601#comment:11>
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/groups/opt_out.