Hi All, I know it would considerably slow down @cached_method, but what about the following: - When a new item for the cache is first computed, test whether it is hashable. - Along with the item, store whether it is hashable or not (so that there's no need to test hashability again). - If an item is taken from cache, the return either the item itself or a (deep?) copy of it, depending on whether it is hashable or not.
In addition to a slow-down, it might break pickles (because it would change the internal format of the cache). So, maybe this is better: Add an option to @cached_method, such as @cached_method(copy=True) def list(self) return list(self) It means that the resulting wrapper of the list() method will use a cache, but will always copy the result before returning it. Cheers, Simon -- 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 https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.