On Tuesday, 21 March 2017 18:30:46 UTC+1, Aaron Meurer wrote:
>
> I like the idea, although we've have to make sure to keep things fast, 
> especially for common objects. 
>

Yes, that's the main problem. A simple idea is to load these preprocessors 
only if the submodules requiring them are loaded. That way, if someone 
needs a fast code, he should just not to load those submodules.


> Maybe each class could have a registry, and at the top of each class, 
> it could have a function that checks each argument against the 
> registry. So for instance, for Add: 
>
> class Add: 
>     preprocess_functions = {} 
>     @classmethod 
>     def flatten(cls, seq): 
>         for i in seq: 
>             if type(i) in cls.preprocess_functions: # really should 
> check for subclass 
>                 return cls(*cls.preprocess_functions(seq)) 
>
>
 This would apply the *preprocess* functions many times if the types are 
repeated.

Is there a way to trigger the preprocessing functions starting from the 
operator?
That is, if you have something like

3+y+A+x

and *A* requires the trigger, one could add a dynamic collection. That is, 
given the evaluation order:

(((3+y)+A)+x)

The second + operator could detect the presence of required triggers in *A*, 
collect them and then apply them when *Add(3, y, A, x)* is called.

Then the units would register Add.preprocess_functions[Unit] = 
> <function that checks unit consistency>. 
>

I would use a set rather than a dict.
 

>
> There are a lot of details to work out here, but is that the basic 
> idea you are suggesting? 
>

Yes, approximately. Maybe it can be further improved by thinking a bit more.

We could experiment with the new unitsystem module as soon as I finish its 
refactoring. 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/468ab060-a073-4684-ad10-db4b0b4fca94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to