If you create an extension type in Cython, something you never want to be subclassed, it is a cpp
class wrapped in a Python class. To prevent this, you can do the following:
cimport cython @cython.final cdef class A: pass cdef class B (A): pass
This annotation will give an error when someone tries to subclass:
pycode.pyx:7:5: Base class 'A' of type 'B' is final
Note that these annotations only work on the cdef
or cpdef
functions and not on normal Python def
functions.