The gap the proposal addresses
The first issue was that the Python Buffer Protocol “didn’t support read and write coordination at the protocol level”. [1]
Storage addresses were stable, but contents were not. [2]
The Buffer Protocol supports a readonly attribute, but this value only applies to a single view, and writable access could not be made exclusive with existing APIs. [3]
Leases and their two modes
Nathan’s proposal to add safe coordination of reads and writes was through new buffer “leasing” C APIs, PyBufferLease and PyBufferAccessState, similar to Rust’s borrowing mechanism. [4]
These APIs would allow consumers to lease a buffer and declare their access pattern ahead of accessing a buffer view. [5]
Leases could be opened in either SHARED_READ or EXCLUSIVE_WRITE mode, and calling PyObject_AcquireBufferLease() would not block, instead immediately either succeeding or failing if an incompatible lease already exists. [6]
EXCLUSIVE_WRITE would provide writable access and exclude every other access to overlapping memory. [7]
What stays the same
The existing PyObject_GetBuffer(), PyBuffer_Release(), and other related interfaces would remain unchanged under Nathan’s proposal. [8]
Buffer exporters would advertise explicit support for the new access modes, and exporters that don’t support the new access APIs would continue to use existing APIs as-is. [9]
Consumers would query the exporter using PyObject_GetBufferAccessModes() and use a lease if the desired access mode is available from the exporter. [10]
Sources
- The Python Software Foundation source says: The first issue was that the Python Buffer Protocol “didn’t support read and write coordination at the protocol level”. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: Storage addresses were stable, but contents were not. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: The Buffer Protocol supports a readonly attribute, but this value only applies to a single view, and writable access could not be made exclusive with existing APIs. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: Nathan’s proposal to add safe coordination of reads and writes was through new buffer “leasing” C APIs, PyBufferLease and PyBufferAccessState, similar to Rust’s borrowing mechanism. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: These APIs would allow consumers to lease a buffer and declare their access pattern ahead of accessing a buffer view. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: Leases could be opened in either SHARED_READ or EXCLUSIVE_WRITE mode, and calling PyObject_AcquireBufferLease() would not block, instead immediately either succeeding or failing if an incompatible lease already exists. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: EXCLUSIVE_WRITE would provide writable access and exclude every other access to overlapping memory. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: The existing PyObject_GetBuffer(), PyBuffer_Release(), and other related interfaces would remain unchanged under Nathan’s proposal. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: Buffer exporters would advertise explicit support for the new access modes, and exporters that don’t support the new access APIs would continue to use existing APIs as-is. Memory Buffer Protocol (Python Language Summit 2026)
- The Python Software Foundation source says: Consumers would query the exporter using PyObject_GetBufferAccessModes() and use a lease if the desired access mode is available from the exporter. Memory Buffer Protocol (Python Language Summit 2026)