[pythran] Re: PEP 576 and PEP 580
- From: serge guelton <sguelton@xxxxxxxxxxxxx>
- To: pythran@xxxxxxxxxxxxx
- Date: Wed, 11 Jul 2018 21:59:08 +0200
On Wed, Jul 11, 2018 at 09:25:16PM +0200, Jeroen Demeyer wrote:
On 2018-07-10 18:03, Serge Guelton wrote:
PEP 576 is easier to understand in terms of implementation and
implication and I can see a clear benefit from the __signature__
attribute. Porting Pythran to use that PEP looks relatively easy.
The __signature__ attribute should really be a separate PEP, it is unrelated
to the rest of PEP 576. Adding support for __signature__ is really a matter
of fixing inspect. And that can be done independently of PEP 576 or PEP 580.
Function call overhead is scarcely an issue for pythran kernel that tend
to be quite computation intensive, but I can imagine situation
(callbacks ? lowlevelcallable) where this would matter.
If you have a concrete use case, that would help.
Here is the simplest example I have in my benchmarks, taken from
#pythran export hasting(float , float, float, float, float, float, float,
import numpy as np
def hasting(y, t, a1, a2, b1, b2, d1, d2):
yprime = np.empty((3,))
yprime = y * (1. - y) - a1*y*y/(1. + b1 * y)
yprime = a1*y*y / (1. + b1 * y) - a2 * y*y / (1. + b2
* y) - d1 * y
When run through pythran, I get
python -m perf timeit -s 'from hasting import hasting; import numpy as np ;
y = np.random.rand(3) ; args = np.random.rand(7)' 'hasting(y, *args)'
Mean +- std dev: 1.35 us +- 0.06 us
while the original code runs in
Mean +- std dev: 3.76 us +- 0.20 us
I'm curious whether changing the calling strategy would have an impact at
Other related posts: