This is very interesting. I actually implemented something along these lines (but not near as complete) before implementing the fast_float stuff. Clearly nothing is going to beat custom-crafted C, but you've given me some motivation to speed up my fast-float code some more :).
One reason I gave up on the invoke-the-compiler method is it just seemed too heavy-weight for the task, both in terms of dependancies (gcc, cython, at writeable temporary directory, getting all the compile-time flags right) and also, in terms of overhead (at 2 microseconds savings/eval, one has to evaluate the function 500,000 times to break even with the 1 second lag, and it falls behind if I'm only evaluating tens of thousand of points). Another advantage is that other functions (for example integration and plotting) can use the _call_c C method which avoids all python overhead (which can be a substantial savings). I'm not trying to dissuade you from using this code, it looks good and is really fast, but figured I'd throw my thoughts on the topic out there. - Robert On Apr 2, 9:02 am, "Ondrej Certik" <[EMAIL PROTECTED]> wrote: > On Wed, Apr 2, 2008 at 5:40 PM, Vinzent Steinberg > > > > <[EMAIL PROTECTED]> wrote: > > > On 1 Apr., 23:46, Mike Hansen <[EMAIL PROTECTED]> wrote: > > > Cool. Does your _compile work with functions where there is no C math > > > equivalent? How long does it take to compile a function? > > > > --Mike > > > Currently it uses only 'math.h' on which the Python module 'math' is > > based. Afaik fast_float does the same. Exotic functions could be > > supported by either implementing them in Cython or by adding a nice C > > math library as a dependency. Is there anything you would wish for? > > > Depending on the function it takes 0.3 s (sqrt(x**2+y**2)) up to 1 s > > (used benchmark function) on my 2.8 GHz CPU. It's probably mainly > > SymPy's fault (I use lambdastr and evalf (to avoid 1/2=0)), so it can > > be optimized. But actually I should not blame SymPy without any > > benchmark :). Hand-written C would probably compile faster, but I > > think 1 s is fine. > > > > Cool, let's put it in then. :) > > > _compile currently accepts only SympPy expressions which it converts > > to lambda strings. So it could also accept lambda strings directly. It > > works exactly like lambdify, it could be merged with it using a flag > > like compile=True. > > Either that, or adding a function cythonify. Or name it "fast_float" > to have the same interface like in Sage. > Excellent, let's do it. > > Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---