What are all the types available in Cython? What are all the types available in Cython? python-3.x python-3.x

What are all the types available in Cython?


You have basically access to most of the C types:

Here are the equivalent of all the Python types (if I do not miss some), taken from Oreilly book cython book

Python bool:

  • bint (boolean coded on 4 bits, alias for short)

Python int and long

  • [unsigned] char
  • [unsigned] short
  • [unsigned] int
  • [unsigned] long
  • [unsigned] long long

Python float

  • float
  • double
  • long double

Python complex

  • float complex
  • double complex

Python bytes / str / unicode

  • char *
  • std::string

For the size_t and Py_ssite_t, keep in mind these are aliases.

Py_ssize_t is defined in python.h imported implicitly in cython. That can hold the size (in bytes) of the largest object the Python interpreter ever creates.

While size_t is a standard C89 type, defined in <stddef.h>.