Brock Mendel schrieb am 21.09.2017 um 21:23:
>> Though there's really no need to have this method at all because
>> Cython inserts it for you autmatically, just do the assignment where
>> you need it, e.g.
>>
>> cdef char* c_string = o
>
> In a perfect world I'd be happy to use that, but the pandas maintainers are
> insisting on micro-benchmarks for essentially anything touching cython or
> C. I've managed to construct cython equivalents for nearly everything in
> numpy_helper.h
> <
https://github.com/pandas-dev/pandas/blob/master/pandas/_libs/src/numpy_helper.h> but
> in most cases the generated C has RefNanny bits that hit performance just
> enough to earn the wrath of the reviewers.
The refnanny is discarded completely in standard builds, so that's not it.
One thing that I could imagine is that Cython needs to do safety
refcounting in some cases that you could avoid in manually written code -
*if you are sure that it's not needed*.
These tiny CPU cycles can still add up to measurable time differences if
they are called thousands or millions of times.
OTOH, micro benchmarks only measure one tiny thing. Switching to a
higher-level language often works as an enabler for implementing
algorithmic improvements that would be too difficult to maintain in a
low-level language, But that obviously depends entirely on the existing
code and the problem at hand...
Stefan