`cpdef`'s C-API Bridge: How Automatic Coercion Works

Cython's `cpdef` achieves automatic type coercion by leveraging Python's C-API, using functions like `PyLong_AsLong` and `PyFloat_AsDouble` to convert Python objects to C types, while also handling crucial error checking and reference counting internally.

Sources

Open the full topic