[issue19078] Allow reversed(memoryview), like memoryview

2013-10-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0dc604d58949 by Nick Coghlan in branch 'default':
Close #19078: memoryview now supports reversed
http://hg.python.org/cpython/rev/0dc604d58949

--
nosy: +python-dev
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-10-02 Thread Nick Coghlan

Changes by Nick Coghlan :


--
assignee:  -> ncoghlan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-10-02 Thread Stefan Krah

Stefan Krah added the comment:

> Stefan, what do you think about Claudiu's patch? Should a test be added to 
> test_buffer as well?

I think the patch is good. We can add more tests when (if?) multi-dimensional
support is added to memoryview.

In that case we should probably do the same as NumPy and return a list of
subviews. So testing against tolist() like in the test case will only work
for one-dimensional views.

I can't commit right now (the machine with my ssh-key won't have Internet
access for some time), so if someone has time to do it ...

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-29 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Claudiu's patch looks correct.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Stefan, what do you think about Claudiu's patch? Should a test be added to 
test_buffer as well?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-28 Thread Claudiu.Popa

Claudiu.Popa added the comment:

For multidimensional arrays it doesn't seem to work (yet).

>>> x = numpy.array([[1,2,3], [4,5,6]])
>>> list(reversed(x))
[array([4, 5, 6]), array([1, 2, 3])]
>>> x.data

>>> list(reversed(x.data))
Traceback (most recent call last):
  File "", line 1, in 
NotImplementedError: multi-dimensional sub-views are not implemented
>>>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-28 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
stage:  -> patch review
type: behavior -> enhancement

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-28 Thread Stefan Krah

Stefan Krah added the comment:

Hmm, I meant: Number of items in the first dimension, thus 4 in
Claudiu's example.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-28 Thread Stefan Krah

Stefan Krah added the comment:

Yes, len() should return the number of items. +1 for making reversed()
work.

NumPy does this:

>>> x = numpy.array([1,2,3,4,5,6,7,8])
>>> list(reversed(x))
[8, 7, 6, 5, 4, 3, 2, 1]
>>>
>>> x = numpy.array([[1,2,3], [4,5,6]])
>>> list(reversed(x))
[array([4, 5, 6]), array([1, 2, 3])]
>>>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-25 Thread Antoine Pitrou

Antoine Pitrou added the comment:

No, you're right, it should probably return 4.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-25 Thread Claudiu.Popa

Claudiu.Popa added the comment:

So, in the following case, len shouldn't return 4, but the number of items? 
Also, is it ok to assume that the number of items is
((*shape)[0] * ... * (*shape)[ndims-1])?

>>> x = np.array([[1, 2, 3], [4, 5, 6], [4,5,6], [4,4,4]], np.int32)
>>> x.shape
(4, 3)
>>> x.shape[0] * x.shape[1]
12
>>> len(x)
4
>>> memoryview(x)

>>> len(memoryview(x))
4
>>> memoryview(x).shape
(4, 3)
>>>

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview

2013-09-23 Thread Nick Coghlan

Nick Coghlan added the comment:

Aye, with the 3.3 changes, I think we should continue down the
multi-dimensional array path. I suggest we run with whatever NumPy uses for
ndarray, which I believe is "number of items in the first dimension".

--
title: Allow reversed(memoryview), like memoryview[::-1] -> Allow 
reversed(memoryview), like memoryview

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview[::-1]

2013-09-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

So the dilemma with len() was: does it return the number of bytes, or the 
number of items?
Given the new memoryview semantics, I'd say it should return the number of 
items.

--
nosy: +ncoghlan, skrah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview[::-1]

2013-09-23 Thread Claudiu.Popa

New submission from Claudiu.Popa:

Hello. The following seems a little weird:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit 
(Intel)] on win32
>>> m = memoryview(b'123')
>>> list(m[::-1])
[51, 50, 49]
>>> list(reversed(m))
Traceback (most recent call last):
  File "", line 1, in 
TypeError: object of type 'memoryview' has no len()
>>>

The attached patch allows `reversed` to be called with memoryviews and it could 
potentially fix issue18690.

--
components: Interpreter Core
files: memoryview.patch
keywords: patch
messages: 198324
nosy: Claudiu.Popa
priority: normal
severity: normal
status: open
title: Allow reversed(memoryview), like memoryview[::-1]
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file31850/memoryview.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue19078] Allow reversed(memoryview), like memoryview[::-1]

2013-09-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com