Am 2014-05-14 11:52, schrieb Nathann Cohen: > Now, it would be COOL if this function could cache its boolean/integer > answers (for we ask the same questions very often), but caching the > matrices is a really (really) bad idea. > > The return type is determined by an argument of orthogonal_array, > existence=True, and we only want to cache answers to that. > > 1) Is there a way to obtain this behaviour with @cached_function ? > 2) If not, do you think that implementing this is a nice idea ? (I am > worried of making the standard use case slower)
+1 to implement filtering what is cached and what not (if it does not slow down the code significantly; from which I think is not the case). FYI: I have a similar problem at the moment: I performing an operation on symbolic expressions. This is done recursively and I want to cache it to improve the speed of my function. The problem is, that I ran out of memory, since the input is sometimes very large, so I want to cache only "smaller" parts. For me "smaller" is whenever operator!=operator.mul of the symbolic input. I wrote a workaround to delete out the not wanted elements of cache directly (every couple of "iterations"), but this is not a very nice solution. So I'd appreciate if cached_function can do that for me. Maybe one could call the function then by: @cached_function(filter=lambda s: s.operator() != operator.mul) def my_function(s): pass Maybe there should be input_filter (=filter) and output_filter instead. Daniel -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.