Am Freitag, 3. Juni 2016 19:19:27 UTC+2 schrieb Volker Braun: > > IMHO we shouldn't slow down cached_method just to allow you to write > incorrect code (and caching a returned list is a bug). If anything, > cached_method should print a warning if the result is mutable so people can > fix their code. >
The "slow down" statement only concerns my first suggestion. I suppose we can forget that first suggestion. But my second suggestion was: Add an option to @cached_method, so that one can request copy-on-return. 1. If one does not choose the new option, it does *not* slow down @cached_method. 2. Chosing the "copy=True" option on methods that may return a list would *fix* the bug that you mention. It would no longer cache a returned list, but it would cache the *copy* of a returned list. It would (usually) still be faster than computing the same list repeatedly, and it would still be as comfortable as the current @cached_method decorator. -- 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.