Am 22.03.2012 22:09, schrieb [email protected]:
I am trying to understand the code at the moment and any help will be
appreciated. My question is: where would I want to use an immutable
matrix?

The only answer I can think of, is as a key for a dictionary.

Immutable data structures are perfect if there is a lot of data sharing: you don't need to do a deep copy "just in case" because you don't know who might be modifying it.

> But a
mutable matrix with a more sophisticated __hash__ should be just as
good...

No, that won't work.
Assume you have two equal mutable matrixes A and B.
Store something under A.
Retrieving something using B as key should return the data stored under A.
Store something under B. It should overwrite what was stored under A.
Now modify B. Should the entry now be associated with A, or with B? They are different, so it must not be the same entry anymore.

(The correct solution would be to use a deep copy of the matrix as a key. Or an ImmutableMatrix.)

--
You received this message because you are subscribed to the Google Groups 
"sympy" 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/sympy?hl=en.

Reply via email to