[Python-Dev] Benchmarks why we need PEP 576/579/580 (original) (raw)

INADA Naoki songofacandy at gmail.com
Mon Jul 23 09:01:22 EDT 2018


On Sun, Jul 22, 2018 at 7:42 PM Jeroen Demeyer <J.Demeyer at ugent.be> wrote:

On 2018-07-22 08:27, INADA Naoki wrote: > It's interesting... But I failed to build sage. What went wrong?

I can't install Sage into my virtual environment, so I can't run

python -m timeit -s "from sage.all import MatrixSpace, GF; M = MatrixSpace(GF(9), 200).randomelement()" "M * M"

But I can run it finally, with sage -python command. And I profiled what is the bottleneck of this oneliner.

https://gist.github.com/methane/91533f68e88f89b7ec7f71855c069792

Cython does optimizations like CPython does internally. When calling function with one arg, and if the function is PyCFunction, Cython call underlaying C function directly.

cfunc = PyCFunction_GET_FUNCTION(func); self = PyCFunction_GET_SELF(func); result = cfunc(self, arg);

This is why such regression happened on even Python 2.7. And I think I can write small benchmark emulate it for now.

-- INADA Naoki <songofacandy at gmail.com>



More information about the Python-Dev mailing list