You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
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
Aaron Meurer
unread,
Jul 13, 2015, 1:51:09 PM7/13/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
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.