On Fri, Sep 10, 2010 at 3:40 PM, Bill Hart <[email protected]> wrote:
> I recently viewed Ondrej's 2007 presentation on SymPy on the web:
> http://www.google.com/url?sa=t&source=web&cd=6&ved=0CCoQFjAF&url=http%3A%2F%2Fsympy.googlecode.com%2Fsvn%2Fmaterials%2Fpresentations%2FSD6.pdf&ei=m7OKTKXUCZDCsAP4-4WIBA&usg=AFQjCNFonE6a4n8zFxYvY3Z9Qy4aQGGrxg&sig2=vEJi5HfUK9emENu5-LOCaA.
> ]
>
> I'm curious about the details of the expression management in sympy,
> which are discussed on slide 14.  Ondrej notes that the sympy strategy
> avoids the creation of intermediate classes, which I think is a great
> idea.  However, I don't quite see how this is done when I look at the
> code.  Can you provide more details about how this is achieved?

We use the __new__ method of Python classes, which is responsible for
classes creation, and so if you do:

a-a

Add.__new__() get's called and inside that class it gets decided to
create a class Integer(0) instead (without creating the intermediate
Add class), in this case, "0" is also cached, but that's a detail.

>
> I'm interested because I've run into performance bottlenecks in my
> Coopr software (specifically in coopr.pyomo), where I'm building
> algebraic expressions and I intermediate class construction is a major
> bottleneck!

Ondrej

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

Reply via email to