Differences between pypy2 and 3 and cffi
Hi, I have an embedded function: @ffi.def_extern() def toint(input,insize,result): for i in range(insize): x = ffi.string(input[i]) result[i] = float(x) if x else 0 return 1 It seems that this runs around 30-40% percent slower in PyPy3 than in 2. Input is a char** c array and result is a float c array. The difference is not in ffi.string If having `result[i] = 1 if x else 0` it runs same in both versions. Any ideas?
I doubt this is an expected result for Pypy3.
But what if you use:
result[i] = float(x) if x else 0.0
...to make result be of homogeneous type?
On Tue, Feb 15, 2022 at 3:36 AM Ioannis Foufoulas
Hi, I have an embedded function:
@ffi.def_extern() def toint(input,insize,result): for i in range(insize): x = ffi.string(input[i]) result[i] = float(x) if x else 0 return 1
It seems that this runs around 30-40% percent slower in PyPy3 than in 2.
Input is a char** c array and result is a float c array. The difference is not in ffi.string If having `result[i] = 1 if x else 0` it runs same in both versions. Any ideas?
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
On Tue, Feb 15, 2022 at 3:36 AM Ioannis Foufoulas
I converted this to an issue https://foss.heptapod.net/pypy/pypy/-/issues/3682 with some timings and analysis of what might be happening. Matti
Nothing changes,
the original implementation was
int(float(x)) if x else 0
However, I so that the overhead was the same if not using int.
Λήψη του BlueMail για Android
Στις 16 Φεβ 2022, 06:24 ,και ώρα 06:24 ,Dan Stromberg
I doubt this is an expected result for Pypy3.
But what if you use: result[i] = float(x) if x else 0.0
...to make result be of homogeneous type?
On Tue, Feb 15, 2022 at 3:36 AM Ioannis Foufoulas
wrote:
Hi, I have an embedded function:
@ffi.def_extern() def toint(input,insize,result): for i in range(insize): x = ffi.string(input[i]) result[i] = float(x) if x else 0 return 1
It seems that this runs around 30-40% percent slower in PyPy3 than in
Input is a char** c array and result is a float c array. The
difference is
not in ffi.string If having `result[i] = 1 if x else 0` it runs same in both versions. Any ideas?
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
We found the problem on the issue that Matti made. It's the float call itself that has gotten slower. It's been fixed and we improved the PyPy2 performance in the process. Tomorrow's nightly should have the change. Cheers, CF On 17.02.22 20:55, Yannis Foufoulas wrote:
Nothing changes, the original implementation was int(float(x)) if x else 0
However, I so that the overhead was the same if not using int.
Λήψη του BlueMail για Android https://bluemail.me Στις 16 Φεβ 2022 ,και ώρα 06:24 ,Dan Stromberg
mailto:drsalists@gmail.com> έγραψε: I doubt this is an expected result for Pypy3.
But what if you use: result[i] = float(x) if x else 0.0
...to make result be of homogeneous type?
On Tue, Feb 15, 2022 at 3:36 AM Ioannis Foufoulas < johnfouf@gmail.com mailto:johnfouf@gmail.com> wrote:
Hi, I have an embedded function:
@ffi.def_extern() def toint(input,insize,result): for i in range(insize): x = ffi.string(input[i]) result[i] = float(x) if x else 0 return 1
It seems that this runs around 30-40% percent slower in PyPy3 than in 2.
Input is a char** c array and result is a float c array. The difference is not in ffi.string If having `result[i] = 1 if x else 0` it runs same in both versions. Any ideas?
_______________________________________________ pypy-dev mailing list pypy-dev@python.org mailto:pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev https://mail.python.org/mailman/listinfo/pypy-dev
_______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
participants (5)
-
Carl Friedrich Bolz-Tereick
-
Dan Stromberg
-
Ioannis Foufoulas
-
Matti Picus
-
Yannis Foufoulas