From 78d7745b4f8ac6d072d6916d8164f0dc712caea7 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Sat, 17 May 2025 19:07:15 +0200 Subject: [PATCH] gh-57089: Note _layout_ in the bitfield docs Co-Authored-By: Meador Inge --- Doc/library/ctypes.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 5b733d5321e907..889c6b76aafc8f 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -714,10 +714,16 @@ item in the :attr:`~Structure._fields_` tuples:: ... ("second_16", c_int, 16)] ... >>> print(Int.first_16) - + >>> print(Int.second_16) - - >>> + + +It is important to note that bit field allocation and layout in memory is not +defined as a C standard; its implementation is compiler-specific. +By default, Python will attempt to match the behavior of a "native" compiler +for the current platform. +See the :attr:`~Structure._layout_` attribute for details on the default +behavior and how to change it. .. _ctypes-arrays: