I am continuing a discussion in a new post.
The issue is that if we take a class such as graphs the instances are
mutable.
It would be useful to have a version which was immutable and therefore
hashable.
For example, we could then use CombinatorialFreeModule to construct
formal linear combinations.
Nicolas has pointed out that:
>
>
In any cases, with Sage 4.4.1, you can actually cheat around this, and
pretend that your graph is immutable:
sage: G = DiGraph(4)
sage: hash(G)
------------------------------------------------------------
Traceback (most recent call last):
...
TypeError: graphs are mutable, and thus not hashable
sage: G._immutable = True
sage: hash(G)
-236023159
This is *dangerous*, so use with all due care. But maybe this can be
sufficient as a workaround for you until a proper mutability
management is implemented for graphs.
>
>
Is the right way to deal with this (and other similar problems) to
have a new class frozengraph
but the types that the data is built up from is changed so that lists,
sequences, etc. are converted
to tuples and dictionaries are converted first to sets and then
frozensets?
...or, is the idea to have a wrapper class that has no methods to
modify the data and then
to declare this immutable? Could a determined user then add a method
which did modify the data?
--
You received this message because you are subscribed to the Google Groups
"sage-combinat-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-combinat-devel?hl=en.