A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-December/084181.html below:

[Python-Dev] Allocation of shape and strides fields in Py_buffer

[Python-Dev] Allocation of shape and strides fields in Py_bufferNick Coghlan ncoghlan at gmail.com
Tue Dec 9 22:22:47 CET 2008
Antoine Pitrou wrote:
> Le mardi 09 décembre 2008 à 22:33 +1000, Nick Coghlan a écrit :
>> memoryview also currently gets the shape wrong on slices:
> 
> I know, that's what I'm trying to fix...

Yes, I was slightly misled by your use of slice assignment to
demonstrate the problem. It also turns out that while assignment to
memoryviews has issues, and so does slicing, there is a fundamental
problem with the length calculation when a memoryview is first created
which is further confusing matters.

For the slicing problem in particular, memoryview is currently trying to
get away with only one Py_buffer object when it needs TWO.

The first Py_buffer object needs to describe the view the memoryview has
of the target object (i.e. it describes the entire data area of the
target). The shape/strides/etc pointers in that struct are owned by the
target object. The existing self->view tends to fill this role fairly well.

The *second* (currently nonexistent) Py_buffer object needs to describe
the memory layout that the memoryview exposes to the rest of the world.
The pointers in *this* struct will be owned by the memoryview object and
accurately reflect any changes in shape due to slicing operations.

Currently, memoryview is trying to make the first Py_buffer also fill
the role of the second one, and that obviously isn't going to work for
subviews.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4