Brock Mendel schrieb am 23.11.2017 um 17:10:
> The docs say* that `@cython.final` applies a small optimization in cases
> where it is applicable. I applied it to _Timestamp.__add__ and
> _Timestamp.__sub__ here
> <
https://github.com/pandas-dev/pandas/pull/18446/files#diff-231ac35d2116a12844a7cfed02730580R215> but
> am not seeing a measurable difference. So two questions:
>
> 1) Are there more specific conditions under which this should give an
> optimization?
It does not currently apply to special methods, which are already faster
than normal Python methods. It would be possible to further speed up
operator usage for final classes here, though, as the lookup currently goes
through a pointer indirection, which still leads to less efficient code
than when telling the C compiler explicitly which exact C function we are
calling, especially because it prevents inlining.
> 2) Ballpark for the size of the optimization?
Depends on your code, as always, but a big difference compared to Python
method calls, and small compared to c(p)def methods and special methods.
Stefan