Most SymPy objects inherit from Basic. Matrix is an exception - this is
necessary because all Basics must be immutable.

Basic objects interact well with each other. This allows things like subs
to work well with very complex/nested objects.

Because ImmutableMatrix is Immutable we can allow it to inherit from Basic
which lets us do lots of fun things.

>From a matrix module perspective ImmutableMatrices can interact with Matrix
Expressions, BlockMatrices, etc... (mutable)Matrix can not.

On Thu, Mar 22, 2012 at 2:29 PM, Joachim Durchholz <[email protected]> wrote:

> 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 sympy+unsubscribe@**
> googlegroups.com <sympy%[email protected]>.
> For more options, visit this group at http://groups.google.com/**
> group/sympy?hl=en <http://groups.google.com/group/sympy?hl=en>.
>
>

-- 
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