> > That happens because we use __slots__ for performance reasons. I was not aware of the __slots__ mechanism. Now I know.
> However, storing attributes in that way is a bad idea in general, > because you risk name conflicts with future versions of SymPy. (That's > also the reason why using subclasses to extend a library tends to break > over time.) OK. On the other hand syntax looks much cleaner > > Alternative 1: You could set up a dict with a Symbol-to-attributes > mapping: Symbols are hashable (that's a guaranteed property). Thats what I meanwhile did (see my other message on this thread). In addition I redefine __setattr__ and __getatrr__ of the Symbol class to hide the dictionary access behind the scene. This feels somehow strange but it works. Lets see how long. > > Alternative 2: We could add a `userdict` attribute in Symbol, so that > SymPy users can store additional attributes there. This would be nice from my point of view. But wouldnt this cause performance issues? As I understand, __slots__ is used to prevent every Symbol instance from having a dict. But introducing a `userdict` would negate this effort. > I'm not too happy with either alternative. > Maybe we can give you better help if you describe your use case in some > more detail. At some point I create symbols from which I know, that they are derivatives and I want to store their order. Using the classes Function and Derivative is no real option because I want the symbols to behave as symbols on most occasions. In general, I think there are situations, where it might be useful to store some algorithm-specific extra information to some symbols. Thanks and Regards, Carsten. -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/555A6B5B.9010808%40gmx.de. For more options, visit https://groups.google.com/d/optout.
