[issue40440] allow array.array construction from memoryview w/o copy

2020-05-06 Thread Benjamin Keen
Benjamin Keen added the comment: memoryview has a lot of overlap with array, but there are still useful methods (index and count for instance) that memoryview does not have. I don't see a workaround that will run with equivalent speed without writing some extension or adding them to

[issue40440] allow array.array construction from memoryview w/o copy

2020-05-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > My sense is it would be a welcome thing to see something like array.array, > that is designed to work with low-level data types, support creation from an > existing buffer without the need for a copy It is called memoryview. --

[issue40440] allow array.array construction from memoryview w/o copy

2020-05-01 Thread Davin Potts
Davin Potts added the comment: Being able to create an array.array without making a copy of a memoryview's contents does sound valuable. We do not always want to modify the size of the array, as evidenced by array.array's existing functionality where its size-changing manipulations (like

[issue40440] allow array.array construction from memoryview w/o copy

2020-04-29 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: array.array should copy the content, to be able to modify it. It implements both the storage for data and the view of that storage. What you want is already implemented as the memoryview object. >>> import array >>> x = array.array('b', [1,2,3,4]) >>> x

[issue40440] allow array.array construction from memoryview w/o copy

2020-04-29 Thread Benjamin Keen
Change by Benjamin Keen : -- keywords: +patch pull_requests: +19121 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19800 ___ Python tracker ___

[issue40440] allow array.array construction from memoryview w/o copy

2020-04-29 Thread Benjamin Keen
New submission from Benjamin Keen : Currently the array.array object can export a memoryview, but there is no way to construct one from a memoryview without making a copy of the underlying data. So in that sense array.array only supports one half of the buffer protocol and this is to allow