This is because SymPy uses __slots__ as a performance/memory optimization. One way to do this would be to create subclasses for the objects that have the attributes you want. There are many issues in SymPy with things not working properly with subclasses, though (but they are bugs and need to be fixed).
Another way might be to put them in the assumptions0 dictionary. I think that might only support boolean attributes, though. Of course, another option would be to store the attributes separately. Aaron Meurer On Mon, Jul 13, 2015 at 6:22 AM, Nico <[email protected]> wrote: > Hi everyone, > > Given a symbolic expression (e.g., "laplace(u) + lambda * u), I'm parsing > that expression to generate code for a particular HPC framework. Up until > now, I'm using custom objects and Python's own AST module to parse the > syntax tree. SymPy, however, could add functionality, so right now I'm > evaluating if it's feasible for me to transition to using SymPy objects for > expressions. > > In the custom parser, I'm adding attributes to nodes to pass around > information. For sympy objects, this is not possible since they don't have a > __dict__. Is there any other way to embellish SymPy objects (such as Add, > Symbol) with extra attributes? > > Cheers, > Nico > > -- > 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/ee33f72a-7986-4451-8035-623086b28420%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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/CAKgW%3D6J%3DrAyi%2B2bvX407bEK53iQK7UyeC%2BFgoAXvtmewcKt6_g%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
