]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-57089: Note _layout_ in the bitfield docs (GH-134148) (GH-135216)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 6 Jun 2025 14:58:48 +0000 (16:58 +0200)
committerGitHub <noreply@github.com>
Fri, 6 Jun 2025 14:58:48 +0000 (14:58 +0000)
(cherry picked from commit b22b964a5c245e13ae0439c5efbb8984acf607ab)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Meador Inge <meadori@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/library/ctypes.rst

index 8e74c6c9dee744307b08348eb5054f884e85fd8e..2ee4450698a1071a437ed01748bd1c7ba5df84ab 100644 (file)
@@ -714,10 +714,16 @@ item in the :attr:`~Structure._fields_` tuples::
    ...                 ("second_16", c_int, 16)]
    ...
    >>> print(Int.first_16)
-   <Field type=c_long, ofs=0:0, bits=16>
+   <ctypes.CField 'first_16' type=c_int, ofs=0, bit_size=16, bit_offset=0>
    >>> print(Int.second_16)
-   <Field type=c_long, ofs=0:16, bits=16>
-   >>>
+   <ctypes.CField 'second_16' type=c_int, ofs=0, bit_size=16, bit_offset=16>
+
+It is important to note that bit field allocation and layout in memory are not
+defined as a C standard; their 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: