Re: [sympy] Lambdify - performance using sympy as the module

2021-09-16 Thread Aaron Meurer
I suppose you might be using f = lambdify(x, sin(x), 'scipy'). This produces a function that calls scipy.sin instead of numpy.sin. However, scipy.sin is just a deprecated wrapper for np.sin, which would explain why it is a little slower. I'm a little unclear why it doesn't raise a deprecation

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-16 Thread Aaron Meurer
What is the difference between "numpy" and "scipy" in your graph? I wouldn't expect scipy to make any difference for sin or cos which are NumPy functions. Aaron Meurer On Wed, Sep 15, 2021 at 7:19 AM Davide Sandona' wrote: > Thanks Oscar for the wonderful clarification! > > I rerun my code

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-15 Thread Davide Sandona'
Thanks Oscar for the wonderful clarification! I rerun my code with SYMPY_USE_CACHE=no, now the results make much more sense. [image: lambdify-no-cache.png] Davide. Il giorno mer 15 set 2021 alle ore 15:14 Oscar Benjamin < oscar.j.benja...@gmail.com> ha scritto: > > On Wed, 15 Sept 2021 at

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-15 Thread Oscar Benjamin
On Wed, 15 Sept 2021 at 13:41, Oscar Benjamin wrote: > On Tue, 14 Sept 2021 at 23:12, sandona...@gmail.com < > sandona.dav...@gmail.com> wrote: > >> Hello, >> let's say I'd like to numerically evaluate a single sympy function over >> an array using sympy as the module. Curiously, passing in

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-15 Thread Oscar Benjamin
On Tue, 14 Sept 2021 at 23:12, sandona...@gmail.com < sandona.dav...@gmail.com> wrote: > Hello, > let's say I'd like to numerically evaluate a single sympy function over an > array using sympy as the module. Curiously, passing in regular Python's > float numbers makes the evaluation much faster

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-15 Thread Aaron Meurer
On Wed, Sep 15, 2021 at 2:36 AM Davide Sandona' wrote: > What are the results you get from these? For me the last one is >> slightly faster, which makes sense because the inputs don't have to be >> converted to SymPy Floats first. >> > > This chart summarizes my findings. Each dot represents the

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-15 Thread Davide Sandona'
> > What are the results you get from these? For me the last one is > slightly faster, which makes sense because the inputs don't have to be > converted to SymPy Floats first. > This chart summarizes my findings. Each dot represents the evaluation time with the specified module + data type. I

Re: [sympy] Lambdify - performance using sympy as the module

2021-09-14 Thread Aaron Meurer
On Tue, Sep 14, 2021 at 4:13 PM sandona...@gmail.com wrote: > > Hello, > let's say I'd like to numerically evaluate a single sympy function over an > array using sympy as the module. Curiously, passing in regular Python's float > numbers makes the evaluation much faster then passing in Sympy's

[sympy] Lambdify - performance using sympy as the module

2021-09-14 Thread sandona...@gmail.com
Hello, let's say I'd like to numerically evaluate a single sympy function over an array using sympy as the module. Curiously, passing in regular Python's float numbers makes the evaluation much faster then passing in Sympy's Float instances. I tried several sympy functions, they tend to follow