This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author davin
Recipients bjkeen, davin, serhiy.storchaka, skrah
Date 2020-05-01.19:59:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588363177.23.0.274146600229.issue40440@roundup.psfhosted.org>
In-reply-to
Content
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 append) are suppressed when exporting a buffer.  So I think it is okay to not require a copy be made when constructing an array.array in this way.

Serhiy's example is a good one for demonstrating how different parts of an array.array can be treated as having different types as far as getting and setting items.  I have met a number of hardware groups in mostly larger companies that use array.array to expose raw data being read directly from devices.  They wastefully make copies of their often large array.array objects, each with a distinct type code, so that they can make use of array.array's index() and count() and other functions, which are not available on a memoryview.

Within the core of Python (that is, including the standard library but excluding 3rd party packages), we have a healthy number of examples of objects that expose a buffer via the Buffer Protocol but they lack the symmetry of going the other way to enable creation from an existing buffer.  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 -- this is the explicit purpose of the Buffer Protocol after all but array.array only supports export, not creation, which currently makes array.array feel inconsistent.
History
Date User Action Args
2020-05-01 19:59:37davinsetrecipients: + davin, skrah, serhiy.storchaka, bjkeen
2020-05-01 19:59:37davinsetmessageid: <1588363177.23.0.274146600229.issue40440@roundup.psfhosted.org>
2020-05-01 19:59:37davinlinkissue40440 messages
2020-05-01 19:59:36davincreate