|
From: Luigi B. <lui...@gm...> - 2021-06-03 07:54:27
|
Hello Alix,
thanks for trying this out. I think SWIG wrappers introduce an
overhead that Cython is able to sidestep, but I might be wrong. You're
welcome to try and optimize the wrappers further, if you want.
Regards,
Luigi
On Wed, Jun 2, 2021 at 9:40 AM Alix Lassauzet <ali...@gm...>
wrote:
> Hello Luigi and QL-community,
>
> I would like to share some of my findings regarding QuantLib performance
> in Python. Over the last few days, I was comparing the speed of SABR
> formula run through 3 different ways in Python: 1/ the pure Python
> implementation (my benchmark), 2/ the exposed Python function via QuantLib
> SWIG, and 3/ the same formula compiled through Cython.
>
> I would expect method 3 with Cython to reach the same level of performance
> of the usual QuantLib-Python from method 2 with a backend in C++, but I am
> surprised to observe Cython is faster than QuantLib-Python by a factor of
> around 2 (see attached python script extracted from a notebook).
>
> QuantLib C++ was compiled with the below command
>
> ./configure --enable-unity-build --disable-static CC=clang CXX=clang++ CXXFLAGS=
> '-O3 -g0 -fPIC'
>
> And then, QuantLib-Python:
> ./configure PYTHON=/usr/bin/python3 CXXFLAGS='-O3'
>
> I also tried to compile PyQL, and I observed the same level of speed-up.
>
> Should I review the compilation of QuantLb in C++ or SWIG to increase the
> performance?
>
> Interested to know any thoughts!
>
> Thanks,
> Alix
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|