On Saturday, April 26, 2014 5:10:28 PM UTC+1, Nils Bruin wrote: > > class NumberField(...): > .... > @cached_method > def class_group(self): > <very expensive operations> > G = AbelianGroup(<invariants>) > return G >
Just split it into the cached computation of the invariants and the uncached construction of the AbelianGroup (if the latter is necessary at all). > @cached_method > def class_field_tower(self): > return [list of relative extensions of self] > would be bad if number fields were CachedRepresentation (and probably is > still bad because they probably use some equivalent strategy) and does not > return the offending objects in plain sight: they are wrapped in a list. If > they were stored in an attribute of a returned object, it would be equally > bad. > Yes, which is why you'd need to walk the referred objects digraph with some depth cutoff in doctest mode. > > Furthermore, the relative extensions wouldn't have canonical > representatives, so ageing the cache out would suddenly lead to a change in > representative field, whereas in small tests, you are always getting back > the same > IMHO that is an unrelated bug. You may only use caching if input/output is essentially unique (equivalent up to unique isomorphism or so). Otherwise you can break pretty much any sufficiently complicated computation by first priming a subset of the cached methods with equivalent-but-not-canonically unrelated input.If you really must pick a representative once and for all then you should be forced to be explicit about the memory leak that you created right there. -- 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.