> All Basic classes are immutable. It shows up in a way that once you > create an instance of any Basic subclass, it represents what you put > there a the creation time. If it changes later, it's a bug. > > Example: x+x calls Add.__new__(x, x), which does canonicalization and > creates an instance of Mul(2, x). Once Mul(2, x) is created, it never > changes. > > It is however useful to have mutable Matrices. That's why they don't > inherit from Basic, because if they did, we get in trouble once you > start using Matrices in expressions. > > If something is still not clear, let's discuss it.
This makes sense. But, clearly, there are some aspects of Basic that are not tied to Basic being mutable: * the is_Function, is_Add, etc. attributes. * I am sure many methods are as well. One problem that I am running into is when I get a Sympy related object, I can't automatically assume that it has the methods and attributes. Thus I have to write code like: if isinstance(o, Basic): if o.is_Function .... having to call isinstance makes the speed advantage of the is_* method irrelevant. The speed advantage is only there if _all_ objects related to Sympy have them. Thus, I think that the _parts_ of Basic that don't make assumptions about mutability should be separated out into a different class like ImmutableBasic. Then classes like Matrix will have all those extra methods. > Yes, I think _dagger_ is useful to have. See the other thread for > general discussion. OK, great. > Thanks for all these questions. It helps to improve the sympy's design. Thanks for answering! Brian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
