Re: [sage-devel] Vector spaces with immutable vectors by default

2021-08-09 Thread David Roe
I actually like this idea a lot. My main concern is that it may not be immediately clear where a hash is being called for a user (for example, using it as an argument to a @cached_method will call __hash__). So when they try to mutate the vector/matrix and it fails, it may be difficult for them t

Re: [sage-devel] Vector spaces with immutable vectors by default

2021-08-09 Thread Nils Bruin
On Monday, 9 August 2021 at 19:43:29 UTC-7 Lorenz Panny wrote: > Have we considered the idea to simply call self.set_immutable() whenever > __hash__ is invoked? I think that would solve Nils' original problem It would solve my problem and it would avoid a whole bunch of problems we'd have with

Re: [sage-devel] Vector spaces with immutable vectors by default

2021-08-09 Thread Lorenz Panny
Have we considered the idea to simply call self.set_immutable() whenever __hash__ is invoked? I think that would solve Nils' original problem and it would mean things run smoothly for users who don't know about mutable and immutable objects. In that case, the exception for trying to modify immuta

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-09 Thread Kwankyu Lee
On Tuesday, August 10, 2021 at 9:07:09 AM UTC+9 Nils Bruin wrote: > It may well be that it's convenient internally to have element > constructors to allow for a "mutable=True/False" flag. It may even help > with implementing the feature under consideration here: making sure that > vector spac

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-09 Thread Nils Bruin
On Monday, 9 August 2021 at 15:54:03 UTC-7 Michael Jung wrote: > I like the idea proposed in https://trac.sagemath.org/ticket/29101 (as > posted by Matthias). Namely, introducing the option mutable=False for the > element constructor. Then your code could be rewritten to > > sum( D[V(v0+w, mutab

Re: [sage-devel] Re: Vector spaces with immutable vectors by default

2021-08-09 Thread Michael Jung
I like the idea proposed in https://trac.sagemath.org/ticket/29101 (as posted by Matthias). Namely, introducing the option mutable=False for the element constructor. Then your code could be rewritten to sum( D[V(v0+w, mutable=False)] for w in W) which should be fine, I guess. Travis Scrimshaw s