+-----------+--------------------+-------------------+-----------------------+-------+
| ``'B'`` | unsigned char | int | 1 | |
+-----------+--------------------+-------------------+-----------------------+-------+
-| ``'u'`` | Py_UNICODE | Unicode character | 2 | \(1) |
+| ``'u'`` | Py_UCS4 | Unicode character | 4 | |
+-----------+--------------------+-------------------+-----------------------+-------+
| ``'h'`` | signed short | int | 2 | |
+-----------+--------------------+-------------------+-----------------------+-------+
+-----------+--------------------+-------------------+-----------------------+-------+
| ``'L'`` | unsigned long | int | 4 | |
+-----------+--------------------+-------------------+-----------------------+-------+
-| ``'q'`` | signed long long | int | 8 | \(2) |
+| ``'q'`` | signed long long | int | 8 | \(1) |
+-----------+--------------------+-------------------+-----------------------+-------+
-| ``'Q'`` | unsigned long long | int | 8 | \(2) |
+| ``'Q'`` | unsigned long long | int | 8 | \(1) |
+-----------+--------------------+-------------------+-----------------------+-------+
| ``'f'`` | float | float | 4 | |
+-----------+--------------------+-------------------+-----------------------+-------+
Notes:
(1)
- The ``'u'`` type code corresponds to Python's unicode character. On narrow
- Unicode builds this is 2-bytes, on wide builds this is 4-bytes.
-
-(2)
The ``'q'`` and ``'Q'`` type codes are available only if
the platform C compiler used to build Python supports C :c:type:`long long`,
or, on Windows, :c:type:`__int64`.
smallerexample = '\x01\u263a\x00\ufefe'
biggerexample = '\x01\u263a\x01\ufeff'
outside = str('\x33')
- minitemsize = 2
+ minitemsize = 4
def test_unicode(self):
self.assertRaises(TypeError, array.array, 'b', 'foo')
a.fromunicode('\x11abc\xff\u1234')
s = a.tounicode()
self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234')
+ self.assertEqual(a.itemsize, 4)
s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
a = array.array('u', s)
Type code C Type Minimum size in bytes \n\
'b' signed integer 1 \n\
'B' unsigned integer 1 \n\
- 'u' Unicode character 2 (see note) \n\
+ 'u' Unicode character 4 \n\
'h' signed integer 2 \n\
'H' unsigned integer 2 \n\
'i' signed integer 2 \n\
'f' floating point 4 \n\
'd' floating point 8 \n\
\n\
-NOTE: The 'u' type code corresponds to Python's unicode character. On \n\
-narrow builds this is 2-bytes on wide builds this is 4-bytes.\n\
-\n\
NOTE: The 'q' and 'Q' type codes are only available if the platform \n\
C compiler used to build Python supports 'long long', or, on Windows, \n\
'__int64'.\n\