#15056: Bind the wrapped function to the instance to which a 
`CachedMethodCaller`
is bound
-------------------------------+----------------------------
       Reporter:  SimonKing    |        Owner:
           Type:  enhancement  |       Status:  needs_review
       Priority:  major        |    Milestone:  sage-5.12
      Component:  misc         |   Resolution:
       Keywords:               |    Merged in:
        Authors:  Simon King   |    Reviewers:
Report Upstream:  N/A          |  Work issues:
         Branch:               |       Commit:
   Dependencies:  #12601       |     Stopgaps:
-------------------------------+----------------------------
Changes (by {'newvalue': u'Simon King', 'oldvalue': ''}):

 * status:  new => needs_review
 * author:   => Simon King


Comment:

 This is now ready for review (and is a prerequisite for #12978).

 The underlying idea: We wrap a function `f`, resulting in a cached method
 `CMf`. When binding `CMf` to an instance `inst` (which can be None), then
 a `CachedMethodCaller` or `CachedMethodCallerNoArgs` `CMCf` is returned,
 according to the number of arguments. Now, the old behaviour was that
 `CMCf` was holding a copy of `f`, and was calling it passing `inst` as the
 first argument.

 Now, in #12978, I envision to wrap arbitrary objects `f`, in particular
 objects with a `__get__` method, so that `f` can be bound to `inst`---and
 obviously it is not `f` but `f bound to inst` what we want to call! As a
 side effect, we can distinguish cached bound methods of an instance, and
 cached unbound methods.

 Outside of sage/misc/cachefunc.pyx, only little had to change. In fact,
 there have just been a few places in which the string representation of a
 cached method appears in a test---and the string representation has
 changed, because it is now `Cached version of <bound/unbound method...>`
 instead of `Cached version of <function ...>`.

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

Reply via email to