[Python-Dev] PEP: Adding data-type objects to Python
Paul Moore
p.f.moore at gmail.com
Thu Nov 2 01:01:40 CET 2006
On 11/1/06, Alexander Belopolsky <alexander.belopolsky at gmail.com> wrote:
> Let's just start with that. The way I see the problem is that buffer protocol
> is fine as long as your data is an array of bytes, but if it is an array of
> doubles, you are out of luck. So, while I can do
>
> >>> b = buffer(array('d', [1,2,3]))
>
> there is not much that I can do with b. For example, if I want to pass it to
> numpy, I will have to provide the type and shape information myself:
>
> >>> numpy.ndarray(shape=(3,), dtype=float, buffer=b)
> array([ 1., 2., 3.])
>
> With the extended buffer protocol, I should be able to do
>
> >>> numpy.array(b)
As a data point, this is the first posting that has clearly explained
to me what the two PEPs are attempting to achieve. That may be my
blindness to what others find self-evident, but equally, I may not be
the only one who needed this example...
Paul.
More information about the Python-Dev
mailing list