On 22 June 2012 22:13, Guru Devanla <[email protected]> wrote:
> Hello All,
>
> Can someone explain why 2 objects in the following statements give me the
> same id() value?
>
>
>>>> A, B = symbols('A B', commutative=False)
>>>> x = A*B
>>>> print id(x)
> 169853492
>>>> y = A*B
>>>> print id(y)
> 169853492

Because these are the same object A*B. x and y are just labels
pointing to an instance.

>
> I run into this problem while trying to implement some operation on Trace
> module.
>
> Say, I have  Tr(A*B*C) . Now, the user wants to create another instance of
> Tr(C*A*B).   But, both objects are getting the same id, meaning I am not
> able to create 2 different objects one which prints at Tr(A*B*C) and another
> which prints as Tr(C*A*B).  Note, that I have not yet overridden
>  _hashable_contents to compare the args ( using the  cyclic property of
> trace).
>
Stupid question: Did you correctly set commutable=False for A,B and C.
Does Tr somehow override them?

> Am I missing something basic?   Or is there a way to override this
>  behavior, if necessary
>
> Thanks
> Guru
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/lFlq7OJjqlkJ.
> 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.

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