How variables are saved in Python and Rust. Side by Side 3: bool
Series article to show how variables work in Python and Rust. Give us a better understanding of both languages. This is the 3rd article about bool.
Background
In this series of articles, I will show how variables work in Python and Rust side by side such that we could have a better understanding of both. In this article, we will check how bool
works in both.
In addition, I am not comparing which language is better. They all have their pros and cons. Also, please comment if there is anything that my understanding is wrong.
Environment
Python: version 3.9.7
Rust: 1.56.1
OS: 64bits Linux 5.12.19–1-MANJARO
Use CPython as the Interpreter of Python
`bool` data type in Python
Before checking any cpython
code, from my “understanding”, the bool
value could be done by 1 bit, 0
or 1
. But considering operation system and memory alignment, maybe 1 byte or 4/8 bytes (32 bits system or 64 bits system) represents the bool
.