0

I need to store a large number of unsigned integers. Looking at https://docs.python.org/3/library/array.html, I wonder why python's array uses 2 bytes for unsigned ints whereas the C language expects 4 bytes in general?

zell
  • 9,830
  • 10
  • 62
  • 115
  • ".. whereas the C language expects 4 bytes in general ..": no. The implementation of `int` in C has shifted over the decades. The proper C name for your 2-byte value is `short`, and a 4-byte integer is a `long`, and their ranges are defined in the C standards. – Jongware Oct 20 '20 at 11:42
  • @usr2564301 All integer types in C are specified only using *minimum* bit-widths. It's guaranteed that `long` is *at least* 32 bits, but it could also be 64 bits (or more, but not bigger than `long long`). – Some programmer dude Oct 20 '20 at 11:47
  • Of course – and so does that table for Python (that column header also says "minimum"). – Jongware Oct 20 '20 at 11:49

0 Answers0