> I think Nils' original solution, of adding an immutable keyword option to > the parent, is a good one. I've run into a similar issue with matrices, > where I had to make them immutable before using them as dictionary keys. >
I also ran into this when implementing Lie algebras over matrices. I had to do special casing and subclasses to get around the mutability that doesn't exist for other classes in Sage. I would like to see some way of working with immutable matrices/vectors. (Internally, we need to mutate stuff in place for efficiency, such as in echelonize(). However, I believe we are all in agreement about still supporting mutable matrices/vectors.) Best, Travis > > > On Fri, Aug 6, 2021 at 7:39 PM Nils Bruin <[email protected]> wrote: > >> On Friday, 6 August 2021 at 16:31:23 UTC-7 [email protected] wrote: >> >>> To clarify, by "similar reasons to numpy", I meant that you open up >>> the possibility of using Cython, vectorized operations, JITs like >>> numba, etc. Some of these provide order of magnitude speedups and >>> aren't an option with generic Python lists. >> >> >> To clarify, this thread certainly didn't start out with the question if >> sage should have mutable vectors at all (although I do think that in most >> cases, an array would then work just as well). I think it is worth >> reconsidering whether all vectors need to start out their life being >> mutable, because that does come with a significant usability penalty in >> hash-related scenarios. >> >> It is indeed the case that we could just spell these examples as >> {tuple(v+w): ... }, and probably that is what cached_function argument >> manglers do, but .... to me that just looks super ugly (and the annoying >> part is that it'll take me a error for every time I need to insert that). >> >> -- >> > 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 [email protected]. >> > To view this discussion on the web visit >> https://groups.google.com/d/msgid/sage-devel/430ef312-156b-4364-8b73-456429d9decan%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sage-devel/430ef312-156b-4364-8b73-456429d9decan%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/ff6aca7e-d2e7-4dd4-99de-4a379d88634en%40googlegroups.com.
