[Cython] Python callable staticmethods?
jpe at wingware.com
Mon Sep 25 15:58:16 EDT 2017
On 9/25/17 3:32 PM, Stefan Behnel wrote:
> Am 25. September 2017 20:59:01 MESZ schrieb John Ehresman:
>> Is there a way to define a Python callable staticmethod in a Cython
>> cdef class?
> Did you try it?
Not fully, I'll admit. I found that the following are invalid in a .pxd:
cdef class Cls:
I later found that just using @staticmethod\n def method(a) in a .py
file does work (I'm using pure mode). That means that cython code in
other modules is doing a PyObject_GetAttr to get the method and then
calling the returned object (admittedly I'm not far enough along to
profile to see if this is a real problem or not).
I think I'm really asking about cpdef staticmethods.
More information about the cython-devel