[Python-Dev] PEP 580 and PEP 590 comparison.
On 2019-04-14 13:34, Mark Shannon wrote:
> I'll address capability first.
I don't think that comparing "capability" makes a lot of sense since
neither PEP 580 nor PEP 590 adds any new capabilities to CPython. They
are meant to allow doing things faster, not to allow more things.
And yes, the C call protocol can be implemented on top of the vectorcall
protocol and conversely, but that doesn't mean much.
> Now performance.
> Currently the PEP 590 implementation is intentionally minimal. It does
> nothing for performance.
So, we're missing some information here. What kind of performance
improvements are possible with PEP 590 which are not in the reference
> The benchmark Jeroen provides is a
> micro-benchmark that calls the same functions repeatedly. This is
> trivial and unrealistic.
Well, it depends what you want to measure... I'm trying to measure
precisely the thing that makes PEP 580 and PEP 590 different from the
status-quo, so in that sense those benchmarks are very relevant.
I think that the following 3 statements are objectively true:
(A) Both PEP 580 and PEP 590 add a new calling convention, which is
equally fast as builtin functions (and hence faster than tp_call).
(B) Both PEP 580 and PEP 590 keep roughly the same performance as the
status-quo for existing function/method calls.
(C) While the performance of PEP 580 and PEP 590 is roughly the same,
PEP 580 is slightly faster (based on the reference implementations
linked from PEP 580 and PEP 590).
Two caveats concerning (C):
- the difference may be too small to matter. Relatively, it's a few
percent of the call time but in absolute numbers, it's less than 10 CPU
- there might be possible improvements to the reference implementation
of either PEP 580/PEP 590. I don't expect big differences though.
> To repeat an example
> from an earlier email, which may have been overlooked, this code reduces
> the time to create ranges and small lists by about 30%
That's just a special case of the general fact (A) above and using the
new calling convention for "type". It's an argument in favor of both PEP
580 and PEP 590, not for PEP 590 specifically.