[Python-Dev] PEP 576/579/580 benchmark: mistune

INADA Naoki songofacandy at gmail.com
Mon Jul 30 07:11:58 EDT 2018


Like previous SageMath bench, this is caused by Cython's
specialization; __Pyx_PyObject_CallOneArg.

It specializing calling PyFunction and PyCFunction, but it doesn't
specialized for calling CyFunction.

Cython can optimize both benchmark with binding, but without PEP 576 nor 580,
by adding calling code specialized for CyFunction to __Pyx_PyObject_CallOneArg.

Of course, this specialization doesn't help (1) calling CyFunction from
Python case and (2) calling CyFunction from C case.  Please don't attack me
about it.
I just survey and report where the overhead in both benchmark with binding=True
in this mail.

I will send another mail about PEP 576 vs 580.
But I'm not good English writer.  It's difficult to explain my opinion
on such sensitive
topic.

Regards,

On Fri, Jul 27, 2018 at 10:38 PM Jeroen Demeyer <J.Demeyer at ugent.be> wrote:
>
> Hello all,
>
> since my latest benchmark for PEP 580 [1] involved SageMath, which is
> quite a big project, I instead propose a much simpler benchmark
> involving mistune.
>
> mistune [2] is a Markdown parser implemented in the Python language. It
> optionally allows Cython compilation. It doesn't use any kind of
> optimization beyond that, but I created a branch [3] to use extension
> types instead of Python classes.
>
> Cython can either use built-in functions/methods or a custom class
> (which is not optimized but which would be optimized with PEP 580).
>
> I benchmarked mistune with custom classes [3] (binding=True, the
> default) and with built-in functions/methods [4] (binding=False). This
> is the median time of 5 runs:
>
> Binding=True: 9.063s
> Binding=False: 8.658s
>
> So this shows again that PEP 580 improves performance in actual
> real-world use cases.
>
>
> Jeroen.
>
>
>
> [1] https://mail.python.org/pipermail/python-dev/2018-July/154740.html
> [2] https://github.com/lepture/mistune
> [3] https://github.com/jdemeyer/mistune/tree/cython_pxd
> [4] https://github.com/jdemeyer/mistune/tree/cython_pxd_nobinding
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/songofacandy%40gmail.com



-- 
INADA Naoki  <songofacandy at gmail.com>


More information about the Python-Dev mailing list