Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
How to import cclasses defined in other source files in pure python mode? #2763
I'm using Cython 0.29.2 in pure python mode with type hints.
The following code snipped works when the two classes are in the same file, but doesn't compile with cython when the two are written in separate files:
# This is in a.py # cython: language_level=3 import cython from .b import B @cython.cclass class A(B): @cython.ccall def add(self: A, h: cython.int, g: cython.int) -> cython.int: return h + g if __name__ == "__main__": a = A() for i in range(100): print(a.add(i, i+1)) print(a.sub(i, i-1))
# This is in b.py # cython: language_level=3 # cython: language_level=3 import cython @cython.cclass class B: @cython.ccall def sub(self: B, h: cython.int, g: cython.int) -> cython.int: return h - g
I couldn't find in the documentation a proper way (decorator?) to handle such an issue.
I'm not sure if this is:
Thank you in advance.
Hmm. So, there is a feature called "cimport from pyx", which can be enabled in the
However, is there any reason for you to not use