Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supporting @staticmethod with `cpdef` #3327

Open
jakirkham opened this issue Jan 26, 2020 · 0 comments
Open

Supporting @staticmethod with `cpdef` #3327

jakirkham opened this issue Jan 26, 2020 · 0 comments

Comments

@jakirkham
Copy link
Contributor

@jakirkham jakirkham commented Jan 26, 2020

It appears that @staticmethod is not supported for cpdef functions. Would be nice if this use case was supported.


As an example I wrote the following code:

cdef class MyClass:
    @staticmethod
    cpdef smeth():
        pass

However saw the following error from Cython:

Error compiling Cython file:
------------------------------------------------------------
...
cdef class MyClass:
    @staticmethod
    cpdef smeth():
         ^
------------------------------------------------------------

smeth.pyx:3:10: static cpdef methods not yet supported

A workaround users might consider in the interim is to define both cdef and def methods manually:

cdef class MyClass:
    @staticmethod
    cdef c_smeth():
        pass

    @staticmethod
    def smeth():
        MyClass.c_smeth()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.