#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 kcrisman):

 > > 1) I need this feature.
 >
 > No. You happen to have a hammer in your hand, and now everything looks
 vaguely similar to nails. Trust me, not everything is a nail and there are
 more elegant solutions to your problem.

 Then write the more elegant solution.  I agree that we can have feature
 creep at times, and I'm sure ncohen does too, based on many comments on
 sage-devel.  But if there is some canonical way to do some specific
 example of Nathann's (obviously not the toy cases in the doctest here)
 then let's add ''that'' to the documentation, so that when other people
 who want to do what he does show up, they can look at a well-annotated
 example of why it's so horrible to do this filtering.  There's no need to
 browbeat.

 > I don't even get how you can honestly deny that filtering what is being
 cached, even if the two functions "don't talk", can be useful.

 Yeah, I'm not sure why this can't be useful either, even if for some
 reason it doesn't need a new decorator.  As a non-cache-expert, I guess
 Volker's suggestion of
 {{{
 bar_cache = dict()

 def bar(x, y, z):
     try:
         return bar_cache[(x,y,z)]
     except KeyError:
         w = do_long_computation(x, y, z)
     if want_to_cache(x,y,z,w):
         bar_cache[(x,y,z)] = w
     return w
 }}}
 seems fine too, especially if documented somewhere.  There has to be some
 compromise here; it's not ''that'' important.  (As opposed to rewriting
 Sage in Ruby or something.)

 ----

 Naturally, I have no ball in the technicalities of this game.  I **do**
 have a ball in the game of people getting along enough to not squabble and
 get personal over this stuff.
 [https://plus.google.com/110464871801965858778/posts/LTnYFQg1fnc "The open
 source community is just so fricking nice"] is what we want people to
 think about when they think of Sage community.

--
Ticket URL: <http://trac.sagemath.org/ticket/16353#comment:29>
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.

Reply via email to