[GiNaC-devel] Add method ex::symbols for obtaining all symbols appearing in an expression

Richard B. Kreckel kreckel at ginac.de
Mon Aug 13 09:02:19 CEST 2012


Hi,

On 08/13/2012 01:19 AM, Timo Kluck wrote:
> You may know the CAS Sage [1] which uses GiNaC. It wraps ginac
> expressions in Python, and it adds some extra methods of its own.
>
> One of those methods is variables(), which returns a list of symbols
> appearing in the expression. It does so by recursively walking down
> the expression tree. At one point, that was a bottle neck in my
> algorithm, and I realized that it would be very easy to cache those
> variables at construction time from the subexpressions.
>
> I think the natural place to implement such a thing would be in GiNaC
> itself, so that everyone (not only sage users) may benefit. Is this
> planned and/or would you accept such a patch?

Wouldn't it be better to go one step further and cache those variables 
when the variables() function is first used? This avoids quite a lot of 
overhead in space and time! And then, variables() wouldn't have to be a 
member function, right?

Cheers
   -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the GiNaC-devel mailing list