You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use alignment "tricks" to speed up core operations on booleans #142584
Branching on a boolean value is a very common operation in the Python VM, as all values are converted to booleans before any branch.
Checking for the truth of a boolean variable in the VM requires either dereferencing the pointer to get at the value or comparing with a full 64 bit pointer.
If we allocate the booleans in an array and align that array by 2*sizeof(PyLongObject) then we can determine the truth of the pointer by simply inspecting a bit in the pointer.
Instead of ptr == Py_True or ptr->ob_digits[0]
we can use a simple bitwise test: ((uintptr_t)ptr) & sizeof(PyLongObject)
Activity
sergey-miryanov commentedon Dec 11, 2025
Is this a duplicate of the #138245?
markshannon commentedon Dec 12, 2025
Yes, it is. Your ability to search GitHUb is clearly superior to mine 🙂
sergey-miryanov commentedon Dec 12, 2025
It's on my favorites list :)