Python explores leases for safer shared memory buffers
Python’s buffer protocol gives consumers access to memory, but a stable address does not guarantee that another participant will leave its contents unchanged. A language-summit proposal explores leases that permit shared readers or an exclusive writer. Incompatible overlapping access would fail immediately, providing an explicit coordination mechanism for participating exporters and consumers.
Python Insider · Sep 30, 2026
Why it matters
This matters for extension authors sharing arrays or other memory, especially as free-threaded execution becomes more common.
More context
Watch the proposed PyBufferLease and PyBufferAccessState work rather than depending on those APIs today. The approach preserves existing interfaces and lets exporters opt in. Consumers would need to discover supported access modes and handle failed lease acquisition.
Keep in mind
These are draft ideas, not shipped Python guarantees. Raw pointers, existing array libraries and exporters that do not participate remain important compatibility challenges. A read-only view alone does not make the underlying memory immutable.
Original read