I'm not sure about this. If you try commenting out the empty __slots__ definition for AtomicExpr, for example, the core tests take almost twice as long (41 seconds for me vs. 25 in master). It's not clear why, though. Commenting out the __slots__ in Basic, which is the only one that I know of that is non-empty, makes the tests take 28 seconds, and commenting out the empty __slots__ for Expr makes them take 38 seconds.
But I imagine if we were to remove all __slots__ definitions in the core, that things would be much slower. Aaron Meurer On Sat, May 5, 2012 at 11:26 AM, Ronan Lamy <[email protected]> wrote: > The only purpose of __slots__ is to save memory, though it doesn't save > a lot. Until PR #1162 gets merged, it's also abused by the pickling > system to give a list of the attributes to save, which makes pickles > unnecessarily large. > > Le samedi 05 mai 2012 à 18:39 +0200, [email protected] a > écrit : >> Slightly related: Why __new__ is used so often instead of simply >> __init__? In basic for example it seams like __init__ is good enough. >> > There are many cases where __new__ has to be used because the class > constructor can return instances of other classes (cf. Add(1, 2)). It > seems easier to use __new__ all the time than to have to worry about the > interaction of __new__ and __init__. A lot of classes in the core have __new__ methods that return Basic.__new__(cls, *args, **kwargs) (do a grep for Basic\.__new__ to see what I mean). Any idea why this is done? Aaron Meurer -- 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.
