The table listing typecodes (probably) contains typos using the following script
import array tc = 'bhilqfd' for t in tc: ar=array.array(t) print(ar.typecode, ar.itemsize)
I get the following itemsize (MacOS 10.13.6 Python 3.8.3) From documentation 3.8.3 b B 1 1 h H 2 2 i I 4 2 typo -> 4 l L 8 4 typo -> 8 q Q 8 8 f f 4 4 d d 8 8
Best regards Francis (native language French)
Thanks for reporting!
On 6/17/20 7:56 PM, Francis Dalaudier wrote:
The table listing typecodes (probably) contains typos
h H 2 2 i I 4 2 typo -> 4 l L 8 4 typo -> 8 q Q 8 8 f f 4 4 d d 8 8
The table titles are:
- Type code - C Type - Python Type - Minimum size in bytes - Notes
You're reporting an erroneos 2 instead of 4 and an erroneous 4 instead of 8, both are documented lower than the value you're getting. As it's labelled "Minimum size", it's correct.
The minimum size for "i" is 2, but we're getting 4. The minimum size for "l" is 4, but we're getting 8.
A paragraph follows the table with further explanation:
The actual representation of values is determined by the machine architecture (strictly speaking, by the C implementation).
Or in the french translation :
La représentation réelle des valeurs est déterminée par l'architecture de la machine (à proprement parler, par l'implémentation C).
In other words, Python does not choose those values, so we can only document known bounds for them, in the Python documentation.
If you think something can be enhanced on the page to make it clearer and help following readers, don't hesitate to tell us, we'll gladly enhance the doc.
Don't hesitate to join the french translation effort here: https://github.com/python/python-docs-fr