[issue23632] memoryview doesn't allow tuple-indexing

2015-03-19 Thread Antoine Pitrou
Antoine Pitrou added the comment: I didn't add the 2d example as the double cast is quite ugly. Probably we should allow casting when the format stays the same. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Pyth

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-19 Thread Roundup Robot
Roundup Robot added the comment: New changeset 7d4eb5902f82 by Antoine Pitrou in branch 'default': Issue #23632: Memoryviews now allow tuple indexing (including for multi-dimensional memoryviews). https://hg.python.org/cpython/rev/7d4eb5902f82 -- nosy: +python-dev _

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: It would be good to add examples with multidimensional memoryviews. For example: >>> a = array.array('l', [-, , -, ]) >>> m = memoryview(a).cast('B').cast('l', [2, 2]) >>> m[0, 0] - >>> m[1, 0] - >>> m[-1, -1] 44

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Updated patch addressing Serhiy's comments. -- Added file: http://bugs.python.org/file38550/memoryview_tuple_indexing2.patch ___ Python tracker

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I left few nitpicks on Rietveld, but in general the patch LGTM. Oh, needed a documentation. -- ___ Python tracker ___ ___

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-18 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- stage: needs patch -> patch review ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Do you want to review the patch? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-14 Thread Stefan Krah
Stefan Krah added the comment: It turns out that msg237933 was too simplistic: There are some intricacies of numpy array indexing that *are* very complex: http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html In particular, x[::2, 1, ::2] is not necessarily equal to x[::2][1][::2].

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Stefan Krah
Stefan Krah added the comment: Yes, to be clear I'm +1 on this specific feature -- and separate issues. :) -- ___ Python tracker ___ _

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Well, we could certainly do both :) I don't think we should weigh this issue with separate features, though. -- ___ Python tracker ___

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Stefan Krah
Stefan Krah added the comment: sub-views and multi-dimensional slicing are not that bad: They're already implemented in _testbuffer (indeed with intermediate objects though). -- ___ Python tracker

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: Sub-views are not as easily implemented. Besides, they create an intermediate object which is immediately thrown away. And tuple indexing is a very common idiom in the Numpy universe. -- ___ Python tracker

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: May be add support of multi-dimensional sub-views? >>> m = memoryview(bytearray(range(12))) >>> m2 = m.cast('B', (3,4)) >>> m2[0] Traceback (most recent call last): File "", line 1, in NotImplementedError: multi-dimensional sub-views are not implemented Th

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Stefan Krah
Stefan Krah added the comment: To be sure, the PEP contains some odd proposals like "Unpacking a long-double will return a decimal object", but the one in this issue seems reasonable. -- ___ Python tracker ___

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Stefan Krah
Stefan Krah added the comment: Multi-dimensional slicing is explicitly mentioned in PEP-3118, so I guess the intention was to cover this use case as well. -- ___ Python tracker _

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread Antoine Pitrou
Antoine Pitrou added the comment: > If we make this work, aren't people going to expect [[1,2], [3,4]][0,1] to > work? Or even [[1,2], [3,4]][*(0,1)] :-) But seriously, I don't know. memorview is a pretty specialized object, its semantics have more to do with Numpy (which has been a major ins

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-12 Thread R. David Murray
R. David Murray added the comment: Aren't there wider implications of python starting to support tuple indexing? If we make this work, aren't people going to expect [[1,2], [3,4]][0,1] to work? -- nosy: +r.david.murray ___ Python tracker

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-10 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here is a patch. -- keywords: +patch Added file: http://bugs.python.org/file38431/memoryview_tuple_indexing.patch ___ Python tracker ___ ___

[issue23632] memoryview doesn't allow tuple-indexing

2015-03-10 Thread Antoine Pitrou
New submission from Antoine Pitrou: It is a bit of pity. A least non-sliced indexing should be able to work: >>> import numpy as np >>> a = np.arange(10) >>> memoryview(a)[0] 0 >>> a = np.arange(10).reshape((2,5)) >>> a[0,1] 1 >>> memoryview(a)[0,1] Traceback (most recent call last): File "",