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 to find out where in the code they need to remove a hash.

An awkward "solution" would be to save the stack when you set it immutable
so that you can print it when the user tries to modify the object.  But I
certainly don't want to add that amount of memory to each vector.  Maybe a
debugging mode for the parent could implement this, but discovery would be
a problem....
David

On Mon, Aug 9, 2021 at 10:43 PM Lorenz Panny <l.s.pa...@tue.nl> wrote:

>
> 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
> immutable vectors should probably explain why the vector was frozen.
>
>
> On Fri, 6 Aug 2021 01:25:08 +0200, Nils Bruin <nbr...@sfu.ca> wrote:
> > Ideas?
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-devel/20210810104118.6c1c6116%40l.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAChs6_kX1nqV0fq6CJRLtcBrg4%2B95pQnG2h-y278OQP51O_OTg%40mail.gmail.com.

Reply via email to