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   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to