In the Risch Algorithm there is a function called build_extension(), which 
takes in an (Expr) expression and converts it into a bunch of Polys, etc. for 
use in the internal Risch Algorithm functions.  Now, currently, it returns a 
tuple of seven items.  Up until now, I have been able to get away with passing 
through two of those items through each function in the algorithm, but around 
the end of the summer I discovered that I really need to be passing at least 
four more of these items.  

So, I decided that the smartest thing to do would be to create a simple object 
to wrap around all of these.  It would just be a simple C struct-like thing, 
something like

class DifferentialExtension(object):
    def __init__(self, f, x):
        vars = build_extension(f, x)
        self.attr0 = vars[0]
        self.attr1 = vars[1]
        etc.

So I did this, but then I got to thinking if it would be smarter to do this 
slightly differently.  For example, would it be better to make 
build_extension() return a DifferentialExtension object (and do away with 
__init__).  Or, since this is the only place in the code where 
build_extension() is ever called (or will ever be called), should I make it a 
method of DifferentialExtension?  Is this method of storing information even 
the best way to do things?

Maybe this all seems superficial, but this is my fourth attempt at an API to 
pass this information around, and I would really like to get it right this 
time.   So which one of these is the most Pythonic?  Object-Oriented 
programming is one of my weak points, so I really don't know how to come up 
with the best design.  One thing I do know is that it is very easy to design a 
poor system using it, so I am ever cautious.  

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.

Reply via email to