Dag Sverre Seljebotn wrote:
> Stefan Behnel wrote:
>> -1 on slices returning views for a sequence type. That is completely
>> unprecedented in Python and would only lead to confusing and buggy code.

> I'm really sorry about forgetting about this not being standard Python. 
> I think you are wrong in it being unprecedented: memoryview seems to 
> support similar behaviour (although I can't quite figure it out and 
> there's no docs on it?)

Here's an example with memoryview:

 >>> A = array.array('i', [0,1,2,3])
 >>> M1 = memoryview(A)
 >>> M2 = M1[2:4]
 >>> M2[0]
b'\x02\x00\x00\x00'
 >>> A[2] = 7
 >>> M2[0]
b'\x07\x00\x00\x00'


So as you see, the slice taken is a view. I mean int[:] to behave like this.

About confusing and buggy code, many years of lots of people using NumPy 
speaks otherwise. I'm only suggesting the same semantics as in NumPy. 
(NumPy arrays can also be backed by different storage coming from other 
libraries etc.)

I spoke with Robert in IRC and he'll try in a new mail to get back to 
the high-level matters at stake (I'm too close to the subject matter to 
succeed it appears), so I'll stop here.

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to