Ticket #3781 (closed enhancement: fixed)

Opened 4 months ago

Last modified 4 months ago

[with patch, with positive review] add a cached_method decorator

Reported by: mhansen Assigned to: cwitty
Priority: minor Milestone: sage-3.1
Component: misc Keywords:
Cc:

Description (Last modified by mabshoff)

mhansen: Does anyone feel up for reviewing #3781 for me?
[4:21pm] ncalexan: I'll look at it, one moment.  I've wanted 
this for a while.
[4:22pm] mhansen: Awesome.  It doesn't work on C extension 
types though since they don't have a __dict__.  This could 
be done by storing the cache in the decorator object with 
a weakref though.
[4:22pm] ncalexan: The problem is much more complicated 
than this.
[4:23pm] ncalexan: Okay, there are other problems too, 
like un-hashable arguments will break it.
[4:23pm] mhansen: Yep
[4:23pm] ncalexan: And there is no way to clear the cache...
[4:23pm] ncalexan: And the tests don't actually demonstrate 
that the cache is workin.
[4:24pm] ncalexan: (One could touch the cache with an 
incorrect answer, then verify it is "correctly" returning 
that value)
[4:25pm] ncalexan: For what it is, though, it's fine.  It 
will hurt nothing -- shall I review positive?
[4:26pm] mhansen: If you could, that'd be great.  I do 
know it's limitations, but there are some big patches 
going in that depend on it.  I'll make a ticket with 
your comments for improvement.
[4:28pm] ncalexan: How big are the big patches?  In fact, 
I don't care -- this declares the intent nicely and can be 
upgraded independently later.  One moment.

Attachments

trac_3781.patch (3.3 kB) - added by mhansen on 08/06/2008 09:34:27 AM.

Change History

08/06/2008 09:34:27 AM changed by mhansen

  • attachment trac_3781.patch added.

08/06/2008 04:31:43 PM changed by ncalexan

  • description changed.
  • summary changed from [with patch, needs review] add a cached_method decorator to [with patch, with positive review] add a cached_method decorator.

08/08/2008 02:42:54 PM changed by mabshoff

  • description changed.

08/08/2008 03:38:45 PM changed by mabshoff

  • status changed from new to closed.
  • resolution set to fixed.

Merged in Sage 3.1.alpha1