On Sun, 15 Apr 2012 19:24:59 -0600, Aaron Meurer <[email protected]> wrote:
> Just a heads up, you'll need to define the free_symbols in your custom
> subclass to include whatever you're taking the derivative of, because
> diff() short-circuits on expressions that don't contain the
> differentiation variable in the free_symbols.  Hopefully that won't be
> too much of a burden on this idea.

I've been thinking about this and have mostly convinced myself that I'll
go the other route instead.

That said, I still do like pymbolic's 'mapper' idea that solves this
(and more) issues with somewhat greater ease.

- It lets you override per-expr-class behavior of each mapper--be it
  'differentiate', 'stringify', or something else, without having to
  rewrite the whole thing.

- It allows a traversal to carry state (the mapper instance).

- A traversal can rebuild the expr tree.

Sympy is either-or on the latter two--a *order_traversal can't rebuild,
but can easily carry state, while the _eval_*() functions can rebuild,
but can't carry extra state.

Andreas

Attachment: pgpVo6aA8DmNQ.pgp
Description: PGP signature

Reply via email to