Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Handling cdef class inheritance and circular cimports #2914
I have the following simplified scenario for my game engine I am writing in cython. I have an "App" cdef class that is responsible for processing a list of "System" cdef class objects. I would like each "System" object to have a reference back to its parent "App" object that it belongs to. The "System" cdef class has some basic functions, and I want to extend this class in sub-cdef-classes (e.g. "GraphicsSystem", "AudioSystem", "PhysicsSystem", etc.). This boils down to the following code:
Attempting to compile this yields the following error message during the cythonization phase:
Commenting out the cimport in the "App" allows the code to compile, and using the "GraphicsSystem" cdef class in other cython modules works without issue. Similarly, cimporting "System" into the app.pxd file works without issues; it appears that just the subclass causes issues during compilation. Any help would be appreciated!
Unfortunately, it does not seem to make a difference modifying the following three cimports as so:
The end result is still the same error as described before.