Ondrej Certik wrote:
> Hi,
> 
> Aaron is now with me in Los Alamos and we are trying to figure out how
> to nicely incorporate the Constant class inside SymPy, it's currently
> in this branch:
> 
> http://github.com/asmeurer/sympy/tree/constant-Mul
> 
> and it works, however, as you can see, it need modifications in the
> Add and Mul classes, and that's bad. The same goes to the Order class,
> which also needs special handling in Mul and Add, and that's bad too.
> 
> I would like to find a solution, so that people can hook up their own
> classes inside sympy and it would just work, yet the core would not
> have to be modified. One thing that we figured out is to use a
> handler, essentially Basic() would have some fast handler, that would
> work for symbols and be fast (using dictionaries). But then Constant
> and Order could override that handler and do their own stuff, like
> O(x)+x -> O(x) and similar things, for which the default handler will
> fail, because O(x) != x, and thus the dictionary approach will fail.

My solution for bringing queries out of the core (I think it's a similar 
problem) was also to consider handler you can add/remove at runtime. 
There was a resolution problem, which I solved with a dictionary mapping 
objects to handlers. You can see source code here:


http://fseoane.net/cgi-bin/gitweb.cgi?p=sympy.git;a=tree;f=sympy/queries;h=c5a1752ed44513d5d7185924e072e126cae6ae4a;hb=refs/heads/queries



If you look at the tests, the last two are about extensibility, just to 
show how easy it is to add new types to the system.



> 
> If anyone has any ideas how to approach this, it'd be awesome --- just
> throw your idea here, no matter how crazy it is.
> 
> Ondrej
> 
> > 
> 


-- 
http://fseoane.net/blog/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to