#14535: Mutability of Graphs
------------------------------------+---------------------------------------
Reporter: SimonKing | Owner: jason, ncohen, rlm
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.10
Component: graph theory | Resolution:
Keywords: mutability graph | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Simon King | Merged in:
Dependencies: #14524 | Stopgaps:
------------------------------------+---------------------------------------
Comment (by nbruin):
Replying to [comment:17 SimonKing]:
> Sure it is a mutation. However, I was told a couple of times that the
"pythonic way" is to pretend that programmers are adult people who know
what they do and who are prepared to take responsibility for their
actions. Hence, while there should be some protection against accidental
changes to an immutable object, it should still be possible to work around
the protection.
This goes a step further, though: Once an object is immutable, people can
use it as a key in a dictionary (and as you know, caching methods such as
`UniqueRepresentation` constructors) can do so in quite unobvious ways.
If you then later allow the object to become mutable again, you have now
made the graph illegal as dictionary key again! (in fact, if you now
mutate it and set it back to mutable, you've made your key unfindable in
the dictionaries. That would create VERY hard to debug bugs (as we've
recently seen on an object that was just inadvertently changing its hash).
There's already precedent: marking a matrix immutable is a one-way street.
Of course, if you really try (and reach in) you can still mutate the
matrix. That's where the "consenting adults" comes in. But changing an
object from immutable to mutable should never be "official" API.
I don't think you'll lose anything. Making an immutable structure mutable
is always a bug. Changing an immutable structure in a way that doesn't
"essentially" change it might not be, but in that case it's reasonable to
expect you can make that change even without the structure being mutable
(e.g., by reaching into the backend to make the change)
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14535#comment:20>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.