Hi SImon, On 6 dic, 00:25, Simon King <simon.k...@uni-jena.de> wrote: > I think that this is the wrong conclusion. It is easily possible to > call the cached method that is inherited from the base class. Also, it > is "class", not "category", by the way: The category framework is not > involved here.
True, I obviously meant class and not category. > B.foo? Is this a copy-and-past error? It should print A.foo. Yep, copy-paste error. > > It is not clear to me why you would try to do A.foo(E) when you can > easily do E.foo(). Because in my original problem, I am trying to over-ride the inefficient base class method with a smarter version. However, the smarter version can fail (due to some sage <-> gap glitches that I will try to solve in due time) and if that happens I want to revert to the original (even if inefficient) method. So my situation is more like this: sage: class A: ....: @cached_method ....: def foo(self): ....: print "A.foo" ....: sage: class B(A): ....: @cached_method ....: def foo(self): ....: try: ....: # some computation that might fail ....: print("B.foo") ....: except: # If the computation fails, fall back to the original A.foo method ....: A.foo(self) As the computations involved are really expensive (explicitly listing all the elements in a conjugacy class), caching the result is a must. > I'd say that it is not a bug and not a feature, but a problem - a > problem that likely is not easy to solve. A cached method is not a > method but an instance of the class "CachedMethodCaller". It is > supposed to behave like a BOUND method, and so you call it like > E.foo(). I might, if it wasn´t overriden by another method in class B. Note that replacing the call A.foo(self) by A.foo() will also not produce the expected result. > > Apparently it would be possible to change the implementation of a > cached method such that A.foo(E) inserts the cached version of foo > into the dictionary of E - but so far it doesn't work. So, you can not > call the cached version of the method by A.foo(E). But it is possible > to call the uncached method, if this is of any help to you: Not really, my fallback method is really expensive (both speed and memory-wise) and I absolutely want to avoid doing the same computations over and over when operating with conjugacy classes. I guess the only way out is to resort to a hand-knitted cache, as probably the overhead of a hand-made definition is less than redoing the whole computation :-/ Thanks for your help! Cheers Javier -- 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