On this page
ctypes.sizeof
Prev: ctypes.SetPointerType | Up: ctypes | Next: ctypes.string_at
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.sizeof
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import sizeof
Signature & Overview
ctypes.sizeof(obj, /)
Return the size in bytes of a C instance.
Usage
import ctypes
assert ctypes.sizeof(ctypes.c_uint64) == 8
assert ctypes.sizeof(ctypes.c_uint8 * 10) == 10
Gotchas
- Matches C
sizeof(...)including struct alignment padding.
REPL Inspect
from ctypes import sizeof
help(sizeof)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/SetPointerType Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/string_at Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ctypes/addressof Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/alignment Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/ArgumentError Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/Array Linked here; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianStructure shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/BigEndianUnion shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/byref shared tags: #ctypes, #stdlib