#16353: A cached_function with selective memory
-------------------------+-------------------------------------------------
Reporter: | Owner:
ncohen | Status: needs_review
Type: | Milestone: sage-6.3
enhancement | Resolution:
Priority: major | Merged in:
Component: | Reviewers:
performance | Work issues:
Keywords: | Commit:
Authors: | 7eb8f900f1a143c6cc85b9382a365b57a9c42ecc
Nathann Cohen | Stopgaps:
Report Upstream: N/A |
Branch: |
u/ncohen/16353 |
Dependencies: |
-------------------------+-------------------------------------------------
Comment (by vbraun):
I did sketch how to organize Nathan's original code already at
https://groups.google.com/d/msg/sage-devel/OPe5VJpBiB4/OswLwqsMJKcJ. I can
make the actual change if Nathan doesn't want do it himself... Honestly,
the filtering feature proposed here is only useful to enable dummy flags
as arguments to functions to change their behaviour:
{{{
@cached_function(filter=lambda x,dummy: dummy)
def foo(x, dummy=False):
if dummy:
return bar(x)
else:
return baz(x)
}}}
If you want to cache bar and not baz then just provide two different
functions. And if you can't split up the function easily because they are
multiple-page case switches then you need to refactor them regardless of
the caching.
--
Ticket URL: <http://trac.sagemath.org/ticket/16353#comment:30>
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.