Skip to content

Add __buffer__ and __release_buffer__ methods to builtin types #5179

Description

@dchiquito

Feature

The buffer protocol is mostly intended to provide provide a C API to access the underlying buffers of data structures like bytes, array, and memoryview. In Python 3.12 two new methods, __buffer__ and __release_buffer__, were added to allow subclasses and custom classes to interface with the C API.

As far as I can tell RustPython does not support the C API, but the appropriate builtin types should still have these slots defined.

Python Documentation or reference to CPython source code

https://docs.python.org/3.12/reference/datamodel.html#emulating-buffer-types
https://peps.python.org/pep-0688/

Activity

  1. added
    C-compatA discrepancy between RustPython and CPython
    on Feb 24, 2024
  2. youknowone commented on Oct 6, 2026

    @youknowone
    Member

    The originally reported problem no longer reproduces on current main. Closing per the recheck in #8982.

    — commented by Grok 4.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions