Generally, I would be in favor of having an option for immutable vectors by 
default, as I had similar uses before. Usually, I just convert everything 
to tuples.

However, I am not sure if having an additional flag on the parent is worth 
the extra burden on maintenance. Already the sparsity flag is not always 
handled correctly (#29359, #29360), immutability may be even easier to 
miss. In my own code, I tend to construct vectors by `vector(ring, [..])`, 
which relies on the uniqueness of the parent and will not preserve 
immutability of vectors. Though, it is fair to say that this code is 
already broken as it does not preserve sparsity either. On the other hand, 
code that is careful about preserving the parent could break if now the 
parent vector space does not allow for mutation. For example, in case of a 
(fabricated) function like

    def f(vec, i):
        w = vec.parent()(0)
        w[i] = vec[i]
        return w

one would have to convert the vector from an immutable vector space to one 
that allows for mutable elements before calling it. This just displaces the 
original problem.


Regarding the performance discussion, (although this was not the question) 
using vectors also has the potential of being much slower than using numpy 
arrays directly.

    sage: a = vector(CDF, [CDF(1, i/(i+1)) for i in range(10^6)])
    sage: %time c1 = a.conjugate()
    Wall time: 4.39 s
    sage: %time c2 = a.parent()(a.numpy().conj())
    Wall time: 11.8 ms

-- 
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/cb07a81a-f414-4316-a7bf-594d5b1a6169n%40googlegroups.com.

Reply via email to