[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread Volker Braun
On Friday, June 3, 2016 at 3:54:57 PM UTC-4, Nils Bruin wrote: > > It could be that the undecorated code is bug-free > That is obviously fine, just don't decorate it with a memoization operator. But don't code that is manifestly wrong with a memoziation operator but then fixed by a subtle varia

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread Nils Bruin
On Friday, June 3, 2016 at 12:42:29 PM UTC-7, Volker Braun wrote: > > > I understood what you want, but I'm saying that its bad to have a bug in > the code that is then worked around by a decorator. Just don't put the bug > in the code to begin with. Apart from being the right thing to do, its al

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread Nils Bruin
On Friday, June 3, 2016 at 11:02:53 AM UTC-7, Simon King wrote: > > > But my second suggestion was: Add an option to @cached_method, so that one > can request copy-on-return. > > -1 for bug trap. We don't know what the correct interpretation of "copy" is. Most of the time, shallow copy will be en

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread Volker Braun
On Friday, June 3, 2016 at 2:02:53 PM UTC-4, Simon King wrote: > > But my second suggestion was: Add an option to @cached_method, so that one > can request copy-on-return. > I understood what you want, but I'm saying that its bad to have a bug in the code that is then worked around by a decorato

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread Simon King
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

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread 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. On Friday, June 3, 2016 at 1:10:25 PM UTC-4, Simon King wrote:

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-03 Thread Simon King
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 i

[sage-devel] Re: Users can permanently modify GF(5).list()

2016-06-02 Thread Simon King
Hi! On 2016-06-02, William Stein wrote: > F.list() > > should return a new list each time just like list(F) does. +1 For efficiency, we might have a version of @cached_method which does store a version of the output once it is computed, but does not directly return what it's in store. Instead,