NumPy C-API - Data Type API
https://docs.scipy.org/doc/numpy/reference/c-api.dtype.html
The standard array can have 24 different data types (and has some support for adding your own types). These data types all have an enumerated type, an enumerated type-character, and a corresponding array scalar Python type object (placed in a hierarchy). There are also standard C typedefs to make it easier to manipulate elements of the given data type. For the numeric types, there are also bit-width equivalent C typedefs and named typenumbers that make it easier to select the precision desired.
标准数组可以有24种不同的数据类型 (并且有一些支持添加自己的类型)。这些数据类型都具有枚举类型,枚举类型字符和相应的数组标量 Python 类型对象 (放置在层次结构中)。还有标准的 C typedef,可以更容易地操作给定数据类型的元素。对于数字类型,还有位宽等效的 C typedef 和命名的 typenumbers,可以更容易地选择所需的精度。
Warning
The names for the types in c code follows c naming conventions more closely. The Python names for these types follow Python conventions. Thus, NPY_FLOAT
picks up a 32-bit float in C, but numpy.float_
in Python corresponds to a 64-bit double. The bit-width names can be used in both Python and C for clarity.
c 代码中类型的名称更紧密地遵循 c 命名约定。这些类型的 Python 名称遵循 Python 约定。因此,NPY_FLOAT 在 C 中获取 32 位浮点数,但 Python 中的numpy.float_
对应于 64 位双精度数。为清晰起见,可以在 Python 和 C 中使用位宽名称。
Enumerated Types
NPY_TYPES
There is a list of enumerated types defined providing the basic 24 data types plus some useful generic names. Whenever the code requires a type number, one of these enumerated types is requested. The types are all called NPY_{NAME}
:
列表中列出了枚举类型,提供了基本的 24 种数据类型以及一些有用的通用名称。只要代码需要类型编号,就会请求其中一个枚举类型。这些类型都称为 NPY_ {NAME}
:
NPY_BOOL
The enumeration value for the boolean type, stored as one byte. It may only be set to the values 0 and 1.
enumeration [ɪ,njuːmə'reɪʃən]:n. 列举,计算,细目
Boolean ['bʊlɪən]:adj. 布尔数学体系的
NPY_BYTE
NPY_INT8
The enumeration value for an 8-bit/1-byte signed integer.
NPY_SHORT
NPY_INT16
The enumeration value for a 16-bit/2-byte signed integer.
NPY_INT
NPY_INT32
The enumeration value for a 32-bit/4-byte signed integer.
NPY_LONG
Equivalent to either NPY_INT or NPY_LONGLONG, depending on the platform.
NPY_LONGLONG
NPY_INT64
The enumeration value for a 64-bit/8-byte signed integer.
NPY_UBYTE
NPY_UINT8
The enumeration value for an 8-bit/1-byte unsigned integer.
NPY_USHORT
NPY_UINT16
The enumeration value for a 16-bit/2-byte unsigned integer.
NPY_UINT
NPY_UINT32
The enumeration value for a 32-bit/4-byte unsigned integer.
NPY_ULONG
Equivalent to either NPY_UINT or NPY_ULONGLONG, depending on the platform.
NPY_ULONGLONG
NPY_UINT64
The enumeration value for a 64-bit/8-byte unsigned integer.
NPY_HALF
NPY_FLOAT16
The enumeration value for a 16-bit/2-byte IEEE 754-2008 compatible floating point type.
NPY_FLOAT
NPY_FLOAT32
The enumeration value for a 32-bit/4-byte IEEE 754 compatible floating point type.
NPY_DOUBLE
NPY_FLOAT64
The enumeration value for a 64-bit/8-byte IEEE 754 compatible floating point type.
NPY_LONGDOUBLE
The enumeration value for a platform-specific floating point type which is at least as large as NPY_DOUBLE, but larger on many platforms.
…
References
NumPy C-API
https://docs.scipy.org/doc/numpy/reference/c-api.html
Python Types and C-Structures
https://docs.scipy.org/doc/numpy/reference/c-api.types-and-structures.html
System configuration
https://docs.scipy.org/doc/numpy/reference/c-api.config.html
Data Type API
https://docs.scipy.org/doc/numpy/reference/c-api.dtype.html
Array API
https://docs.scipy.org/doc/numpy/reference/c-api.array.html
Array Iterator API
https://docs.scipy.org/doc/numpy/reference/c-api.iterator.html
UFunc API
https://docs.scipy.org/doc/numpy/reference/c-api.ufunc.html
Generalized Universal Function API
https://docs.scipy.org/doc/numpy/reference/c-api.generalized-ufuncs.html
NumPy core libraries
https://docs.scipy.org/doc/numpy/reference/c-api.coremath.html
C API Deprecations
https://docs.scipy.org/doc/numpy/reference/c-api.deprecations.html
Interfacing With Other Languages
https://scipy-cookbook.readthedocs.io/items/idx_interfacing_with_other_languages.html
C Extensions for Using NumPy Arrays
https://scipy-cookbook.readthedocs.io/items/C_Extensions_NumPy_arrays.html
C extensions
https://scipy-cookbook.readthedocs.io/items/C_Extensions.html
Ctypes
https://scipy-cookbook.readthedocs.io/items/Ctypes.html
F2py
https://scipy-cookbook.readthedocs.io/items/F2Py.html
Inline Weave With Basic Array Conversion (no Blitz)
https://scipy-cookbook.readthedocs.io/items/Weave.html
SWIG Numpy examples
https://scipy-cookbook.readthedocs.io/items/SWIG_NumPy_examples.html
SWIG and Numpy
https://scipy-cookbook.readthedocs.io/items/SWIG_and_NumPy.html
SWIG memory deallocation
https://scipy-cookbook.readthedocs.io/items/SWIG_Memory_Deallocation.html
f2py and numpy
https://scipy-cookbook.readthedocs.io/items/f2py_and_NumPy.html
Scipy Lecture Notes
https://scipy-lectures.org/index.html
2.8. Interfacing with C
https://scipy-lectures.org/advanced/interfacing_with_c/interfacing_with_c.html