🌐
Python
docs.python.org › 3 › c-api › buffer.html
Buffer Protocol — Python 3.14.8 documentation
Otherwise, the exporter MAY provide either a read-only or writable buffer, but the choice MUST be consistent for all consumers. For example, PyBUF_SIMPLE | PyBUF_WRITABLE can be used to request a simple writable buffer.
Discussions

Buffer protocol types
We had several typeshed issues and pull requests lately that try to work around the fact that there is no way to express that a method receives any object following the buffer protocol. The typing ... More on github.com
🌐 github.com
21
November 20, 2018
What is the Python 'buffer' type for? - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Turn scattered docs and code into trusted AI context. Explore the new Stack Internal platform More on stackoverflow.com
🌐 stackoverflow.com
Accept `ReadableBuffer` instead of `bytes` in `base64` encode functions?
Right now, all of the encode methods in base64 accept bytes but the docs say that they should (and do) accept any bytes-like object. typeshed/stdlib/base64.pyi Line 49 in 536f783 def b64encode(s: b... More on github.com
🌐 github.com
1
April 6, 2022
python - How do I add a type hint for a WriteableBuffer parameter? - Stack Overflow
I'm trying to add a parameter type to the readinto() method declared in a custom class that derives from RawIOBase, like this: from io import RawIOBase class Reader(RawIOBase): def readinto(se... More on stackoverflow.com
🌐 stackoverflow.com
🌐
CircuitPython
docs.circuitpython.org › projects › adafruit-circuitpython-typing › en › latest › api.html
circuitpython_typing — Adafruit CircuitPython circuitpython_typing Library 1.0 documentation
circuitpython_typing.ReadableBuffer · Classes that implement the readable buffer protocol. alias of array | bytearray | bytes | memoryview | rgbmatrix.RGBMatrix | ulab.numpy.ndarray · circuitpython_typing.WriteableBuffer · Classes that implement the writeable buffer protocol.
🌐
GitHub
github.com › python › typing › issues › 593
Buffer protocol types · Issue #593 · python/typing
November 20, 2018 - We had several typeshed issues and pull requests lately that try to work around the fact that there is no way to express that a method receives any object following the buffer protocol. The typing ...
Author: python
🌐
CircuitPython
docs.circuitpython.org › projects › busdevice › en › 5.1.8 › _modules › adafruit_bus_device › i2c_device.html
adafruit_bus_device.i2c_device — Adafruit CircuitPython Bus Device 1.0 documentation
:param ~ReadableBuffer buffer: buffer containing the bytes to write :param int start: Index to start writing from :param int end: Index to read up to but not include; if None, use ``len(buf)`` """ if end is None: end = len(buf) self.i2c.writeto(self.device_address, buf, start=start, end=end) ...
🌐
Adafruit
learn.adafruit.com › creating-and-sharing-a-circuitpython-library › typing-information
Typing Information | Creating and sharing a CircuitPython library | Adafruit Learning System
July 31, 2017 - try: # imports used only for typing from typing import Tuple # <- this line causes the error # any imports below this won't happen if the error gets raised from circuitpython_typing import ReadableBuffer from busio import I2C except ImportError: pass # ignore the error
🌐
CircuitPython
docs.circuitpython.org › projects › adafruit-circuitpython-typing › en › latest
Introduction — Adafruit CircuitPython circuitpython_typing Library 1.0 documentation
Examples · Simple test · API Reference · circuitpython_typing · Alarm · AudioSample · BlockDevice · BlockDevice.readblocks() BlockDevice.writeblocks() ByteStream · ByteStream.read() ByteStream.write() FrameBuffer · ReadableBuffer · WriteableBuffer ·
Find elsewhere
🌐
Python.org
discuss.python.org › peps
PEP 688: Making the buffer protocol accessible in Python - Page 2 - PEPs - Discussions on Python.org
May 1, 2022 - I just posted PEP 688 to support static typing of buffer objects: Summary: Add types.Buffer for use in isinstance/issubclass checks for the buffer protocol. (Implemented through an __instancecheck__ written in C tha…
🌐
Python Data Science Handbook
jakevdp.github.io › blog › 2014 › 05 › 05 › introduction-to-the-python-buffer-protocol
An Introduction to the Python Buffer Protocol | Pythonic Perambulations
And then include this structure in the Python Type definition. static PyTypeObject PyMyArrayType = { ... &PyMyArray_as_buffer, /* tp_as_buffer */ ... } ... This was just a simple example of defining the buffer protocol for an object in CPython. It's exactly the kind of description I wished I had had as I tried to figure out how this stuff worked.
🌐
Python
peps.python.org › pep-0688
PEP 688 – Making the buffer protocol accessible in Python | peps.python.org
April 23, 2022 - The C buffer protocol supports many options, affecting strides, contiguity, and support for writing to the buffer. Some of these options would be useful in the type system. For example, typeshed currently provides separate type aliases for writable and read-only buffers.
🌐
GitHub
github.com › python › typeshed › issues › 7601
Accept `ReadableBuffer` instead of `bytes` in `base64` encode functions? · Issue #7601 · python/typeshed
April 6, 2022 - Right now, all of the encode methods in base64 accept bytes but the docs say that they should (and do) accept any bytes-like object. typeshed/stdlib/base64.pyi Line 49 in 536f783 def b64encode(s: b...
Author: python
🌐
Delft Stack
delftstack.com › home › howto › python › buffer interface in python
Buffer in Python | Delft Stack
March 11, 2025 - The buffer interface in Python provides a way for Python objects to expose their underlying byte data. This is particularly useful for performance-critical applications where raw byte manipulation is necessary. The buffer interface allows objects to share memory without copying data, which can significantly improve the efficiency of your programs. When you work with data types like bytes, bytearray, or even NumPy arrays, you are often interacting with the buffer interface.
🌐
Medium
medium.com › @AlexanderObregon › how-pythons-memoryview-and-buffers-work-23c489fbbabb
How Python’s Memoryview and Buffers Work | Medium
August 11, 2024 - In Python, the buffer protocol is implemented through a set of C-level interfaces that enable one object to expose its data buffer to another. Objects that support the buffer protocol include built-in types like bytes, bytearray, and third-party types like NumPy arrays.
🌐
Python
docs.python.org › 2.0 › api › bufferObjects.html
7.2.3 Buffer Objects
Return value: New reference. Return a new read-only buffer object. This raises TypeError if base doesn't support the read-only buffer protocol or doesn't provide exactly one buffer segment, or it raises ValueError if offset is less than zero. The buffer will hold a reference to the base object, and the buffer's contents will refer to the base object's buffer interface, starting as position offset and extending for size bytes.
🌐
Stack Overflow
stackoverflow.com › questions › 76738308 › how-do-you-get-anystr-joiniterableanystr-to-pass-type-checks
python - How do you get AnyStr.join(Iterable[AnyStr]) to pass type checks? - Stack Overflow
July 21, 2023 - Copy/tmp/type_demo.py /tmp/type_demo.py:7:27 - error: Argument of type "Iterable[AnyStr@joiner]" cannot be assigned to parameter "__iterable_of_bytes" of type "Iterable[ReadableBuffer]" in function "join" "Iterable[AnyStr@joiner]" is incompatible with "Iterable[ReadableBuffer]" TypeVar "_T_co@Iterable" is covariant Type "str* | bytes*" cannot be assigned to type "ReadableBuffer" "str*" is incompatible with protocol "ReadableBuffer" "__buffer__" is not present (reportGeneralTypeIssues) /tmp/type_demo.py:9:27 - error: Argument of type "Iterable[AnyStr@joiner]" cannot be assigned to parameter "__
🌐
Python
docs.python.org › 3.11 › c-api › objbuffer.html
Old Buffer Protocol — Python 3.11.16 documentation
Returns a pointer to a read-only memory location containing arbitrary data. The obj argument must support the single-segment readable buffer interface. On success, returns 0, sets buffer to the memory location and buffer_len to the buffer length.