Benjamin Keen <benjamin.k...@hpe.com> 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 memoryview.

Constructing an array from the memoryview when one wants these isn't a 
workaround because there may not be enough memory to make a copy. For instance 
- a memoryview of a mapped disk file that is much larger than the physical 
memory in the machine.

When writing functions that use an array you don't always know ahead of time 
whether you are going to be in this situation.  The functions may come from 
someone else with a bigger machine. This lets the client of the function decide 
what the right thing to do is as needed without changing the function itself.

So for that reason this brings something that just using the memoryview 
directly won't provide.  There's value in being able to write things that use 
the array interface consistently.

You could also think of this as a way of providing compiled-speed index() and 
count() on certain memoryviews without needing to add new code for that to 
memoryview itself.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40440>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to