Skip to content

Comments

bpo-40440: memoryview construction of array.array without copy#19800

Closed
bjkeen wants to merge 1 commit intopython:mainfrom
bjkeen:memoryview2array
Closed

bpo-40440: memoryview construction of array.array without copy#19800
bjkeen wants to merge 1 commit intopython:mainfrom
bjkeen:memoryview2array

Conversation

@bjkeen
Copy link

@bjkeen bjkeen commented Apr 29, 2020

Currently array.array can export a memoryview but can't construct
from one without copying the underlying buffer - so array supports
only half of the buffer protocol.

This patch allows construction of a new array from a memoryview,
using the memoryview's memory as its underlying buffer.
The resulting array object behaves the same as an array object that
has exported buffers: all methods except those that would move or
resize or free the underlying buffer are available.

https://bugs.python.org/issue40440

Currently array.array can export a memoryview but can't construct
from one without copying the underlying buffer - so array supports
only half of the buffer protocol.

This patch allows construction of a new array from a memoryview,
using the memoryview's memory as its underlying buffer.
The resulting array object behaves the same as an array object that
has exported buffers: all methods except those that would move or
resize or free the underlying buffer are available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants