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 schrieb am Montag, 9. August 2021 um 07:14:41 UTC+2:

> 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 <nbr...@sfu.ca> wrote:
>>
>>> On Friday, 6 August 2021 at 16:31:23 UTC-7 wst...@gmail.com 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 sage-devel+...@googlegroups.com.
>>>
>> 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 sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/dd99fa00-eb30-4b0c-beed-5ed9f16da1e0n%40googlegroups.com.

Reply via email to