array
The array module defines a new object type, array, that works almost exactly like other sequence types, except that its contents are constrained to a single type. The type of an array is determined at the time of creation, using one of the following type codes:
Type Code | Description | C Type | Minimum Size (in Bytes) |
---|---|---|---|
‘c’ | 8-bit character | char | 1 |
‘b’ | 8-bit integer | signed char | 1 |
‘B’ | 8-bit unsigned integer | unsigned char | 1 |
‘u’ | Unicode character | PY_UNICODE | 2 or 4 |
‘h’ | 16-bit integer | short | 2 |
‘H’ | 16-bit unsigned integer | unsigned short | 2 |
‘i’ | Integer | int | 4 or 8 |
‘I’ | Unsigned integer | unsigned int | 4 or 8 |
‘l’ | Long integer | long | 4 or 8 |
‘L’ | Unsigned long integer | unsigned long | 4 or 8 |
‘f’ | Single-precision float | float | 4 |
‘d’ | Double-precision float | double | 8 |
The representation of integers and long integers is determined ...
Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.