On a second thought, if I cache the method in B as well, when I call
the
(uncached) method in A the result will be cached in B, right?

So something like this will work:

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:
....:             A.foo.f(self)

Indeed, using this stuff for my conjugacy classes code as above I get
good timings:

sage: F = GF(5)
sage: gens = [matrix(F,2,[1,2, -1, 1]), matrix(F,2, [1,1, 0,1])]
sage: H = MatrixGroup(gens)
sage: h = H(matrix(F,2,[1,2, -1, 1]))
sage: C = ConjugacyClassGAP(H,h)
sage: time S = C.set()
Time: CPU 0.34 s, Wall: 0.35 s
sage: time S = C.set()
Time: CPU 0.00 s, Wall: 0.00 s


So it really looks like this solves my problem. Thanks again Simon!

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

Reply via email to