Data Type in Python
Python Integer store elements together with their type info, namely, PyObject_HEAD So does list, elements in list can be different type for extra information about data type are stored. Different from C, python list store pointer of the data for better flexibility of data. For list with elements in uniform data type, turn to array
import array
A = array.array(list(range(10))
A
==================================
Numpy
common data type
Data type | Description |
---|---|
int64 | 64-bit integer, storing value from about -9e18 to 9e18 |
uint64 | unsigned 64-bit integer, storing value from 0 to about 18e18 |
complex128 | complex number represented by two 64-bit floats |
float_ | shorthad for double precision-float, sign bit, 11 bits exponent, 52 bits mantissa |
float32 | single precise float, sign bit, 8 bits exponent, 23 bits mantissa |