Python code to check if Raspberry OS are Running in 32-bit or 64-bit

Python sys.maxsize is an integer giving the maximum value a variable of type Py_ssize_t can take. It’s usually 2**31 - 1 on a 32-bit platform and 2**63 - 1 on a 64-bit platform. Using it, Python code can check if running OS is 32-bit or 64-bit.

import sys
import os

print(os.uname())
print(os.uname()[1], os.uname()[4])

print("Is it 64 bit?", sys.maxsize > 2**32)

Run on Raspberry Pi 5/64-bit Raspberry Pi OS (bookworm):


Run on Raspberry Pi 4B/32-bit Raspberry Pi OS (bookworm):


Comments

Popular posts from this blog

480x320 TFT/ILI9488 SPI wih EP32C3 (arduino-esp32) using Arduino_GFX Library

MicroPython/ESP32-C3 + 1.8" 128x160 TFT ST7735 SPI, using boochow/MicroPython-ST7735 library.