On this page
ctypes.resize
Prev: ctypes.pointer | Up: ctypes | Next: ctypes.set_errno
Rel: ctypes.addressof, ctypes.alignment, ctypes.ArgumentError, ctypes.Array
Ref: docs.python.org — ctypes.resize
Tags: #public #python3 #stdlib #ctypes
Import
import ctypes
from ctypes import resize
Signature & Overview
ctypes.resize(obj, size, /)
ctypes.resize() function.
Usage
import ctypes
buf = ctypes.create_string_buffer(4)
ctypes.resize(buf, 8)
assert ctypes.sizeof(buf) == 8
Gotchas
- Can only grow, never shrink below the original type's size: Doesn't change
len(buf)on fixed array types—mostly for variable-length C structs.
REPL Inspect
from ctypes import resize
help(resize)
Linked from
Related notes
- tuts/python3/stdlib_module/ctypes/pointer Linked here; links to this page; shared tags: #ctypes, #stdlib
- tuts/python3/stdlib_module/ctypes/set_errno 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