gh-57089: Note _layout_ in the bitfield docs (GH-134148)

Co-authored-by: Meador Inge <meadori@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
This commit is contained in:
Petr Viktorin 2025-06-06 16:51:40 +02:00 committed by GitHub
parent 1adca08d65
commit b22b964a5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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: