Extension Types (`cdef class`) for C-Level Objects

Defining classes with `cdef class` creates extension types, which store fields and methods in C structs, not Python dictionaries. This allows direct C-level attribute access and method calls, leading to more memory-efficient and significantly faster object-oriented code compared to generic Python classes.

Sources

Open the full topic