Hi Florent, On 28 Mai, 18:12, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote: > Just to let you know, I tried the following work around: > > ... > but since A.toto.f.__name__ is still toto. It doesn't work. However the > following works (on unpatched sage-4.6.2): > > def change_name(fun, name): > fun = copy(fun) > fun.__name__ = name > return fun > > class CC(A): > toto_cached = cached_method(change_name(A.toto.f, "toto_cached")) > def toto(self, arg=2): > return self.toto_cached(arg)
Note that my patch adds an optional argument "name" to the cached method decorator. So, your work-around is easily possible with my patch: sage: class A(SageObject): ....: @cached_method ....: def toto(self,arg): ....: return arg+1 ....: sage: class CC(A): ....: toto_cached = cached_method(A.toto.f,name="toto_cached") ....: def toto(self,arg=2): ....: return self.toto_cached(arg) ....: sage: c = CC() sage: c.toto() 3 sage: c.toto() 3 sage: c.toto() is c.toto() True However, it is a work-around and not an actual solution, IMO. Cheers, Simon -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org