Skip to content

Conversation

davidhewitt
Copy link
Member

I was studying our buffer implementation in preparation to offer some solutions for #5245.

I think the Pin component of PyBuffer<T> is not needed. Quoting the Python documentation for bf_releasebuffer:

a consumer MAY pass a copy of the original buffer as the view argument

This implies to me that the claim Python expects the buffer structure never to move is untrue. (I think this was originally introduced by me being overly cautious in the past.)

Anyway, with the diff proposed here the buffer structure is still heap allocated so that the ffi::Py_buffer structure still isn't moving.

Marked as CI-skip-changelog as I think this is purely internal.

@davidhewitt davidhewitt added the CI-skip-changelog Skip checking changelog entry label Sep 7, 2025
@davidhewitt davidhewitt added this pull request to the merge queue Sep 15, 2025
Merged via the queue into PyO3:main with commit 6f02125 Sep 15, 2025
44 of 45 checks passed
@davidhewitt davidhewitt deleted the remove-buffer-pin branch September 15, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-skip-changelog Skip checking changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants