There are several caveats worth noting when it comes to Cython while mixing C and the Python code. As for me, I tend to keep the interfaces between the C and Python projects as simple as possible so that it's clear when and where something wrong is going on.
You may have noticed that in previous code examples, we were able to cast the
void * pointer from
malloc to our extension types using
malloc. Cython supports some more advanced type checking, for example:
char * buf = <char *> malloc (sizeof (...))
In basic type casting, Cython supports
<type?> for type checking for example:
char * buf = <char *?> malloc (...)
This will do some type checking and will throw an error if the type being cast is not a subclass of ...