Skip to content

Guide for parents with immutable elements #32353

@kwankyu

Description

@kwankyu

This ticket aims to solve the issue that arose in the thread

https://groups.google.com/g/sage-devel/c/DNrbtItMVmQ

(related tickets #29101, #30302, #30239, #23436, #14681, #13811, #19813) by implementing parents with immutable elements, which exist side by side with their twin parents with mutable elements.

The following table serves as a guide for the implementation:

V=VectorSpace(R, 2, mutable=True) new element W=VectorSpace(R, 2, mutable=False) new element
v, v w, w'
v+v' O w+w'
v+w, w+v O
V(v) O W(w) X
V(w) O W(v) O
V(0) O W(0) X
V.zero() O W.zero() X
V([2,3]) O W([2,3]) O
vector(v) O vector(w) X
vector(R, 2) O
vector(R, [2,3]) O vector(R, [2,3], mutable=False) O
copy(v) O copy(w) O
v.mutable() X w.immutable() X
w.mutable() O v.immutable() O
In the table, elements on the left belongs to V; elements on the right to W.

Most parents in Sage have immutable elements and hence don't accept mutable argument. Parents that accept mutable argument defaults to mutable=True.

Parents that accept mutable argument are: VectorSpace, MatrixSpace, FreeModule, Graph

CC: @kliem @mjungmath @tscrim @egourgoulhon

Component: algebra

Issue created by migration from https://trac.sagemath.org/ticket/32353

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions