On Mon, Sep 25, 2017 at 12:58 PM, John Ehresman <j...@wingware.com> wrote: > 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: > > @staticmethod > def method(a) > > @staticmethod > cpdef method(a) > > 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.
You can write cdef static methods and "def" static methods, but cpdef is not yet supported. _______________________________________________ cython-devel mailing list cython-devel@python.org https://mail.python.org/mailman/listinfo/cython-devel