cdef list my_list in Cython
cython, python
Solution
`cdef`ing a Python data type just allows Cython to take a few (small) shortcuts and to type-check.
This will not result in significantly faster code, as the Python overhead still exists. For convenient data types you'll wanting to be using `numpy.array` or `cpython.array.array` typed to a memoryview.
Problem
I am confused about the following code that I see in a lot of places: ``` cdef list my_list ``` I am confused because list is not a C data type, but a Python data type. Why would people use `cdef` instead of `def` then? I like this feature a lot, because sometimes I need to use list in my code and it will take a tremendous amount of effort to restructure my code to C without a python list. I am just confused how and what Cython is doing, when a `list` was defined by `cdef` and have all the methods exposed to us. I tried to search the document, but without luck. Any help would be appreciated!