[Python-3000-checkins] r66374 - in python/branches/py3k: Doc/library/stdtypes.rst Lib/test/test_memoryview.py Misc/NEWS Objects/memoryobject.c

benjamin.peterson python-3000-checkins at python.org
Wed Sep 10 23:47:03 CEST 2008


Author: benjamin.peterson
Date: Wed Sep 10 23:47:03 2008
New Revision: 66374

Log:
kill memoryview.size in favor of len(view)

Reviewer: Antoine Pitrou #3827


Modified:
   python/branches/py3k/Doc/library/stdtypes.rst
   python/branches/py3k/Lib/test/test_memoryview.py
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Objects/memoryobject.c

Modified: python/branches/py3k/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/py3k/Doc/library/stdtypes.rst	(original)
+++ python/branches/py3k/Doc/library/stdtypes.rst	Wed Sep 10 23:47:03 2008
@@ -2246,6 +2246,8 @@
    buffer protocol.  Builtin objects that support the buffer protocol include
    :class:`bytes` and :class:`bytearray`.
 
+   ``len(view)`` returns the total number of bytes in the memoryview, *view*.
+
    A :class:`memoryview` supports slicing to expose its data.  Taking a single
    index will return a single byte.  Full slicing will result in a subview::
 
@@ -2322,10 +2324,6 @@
       A tuple of integers the length of :attr:`ndim` giving the size in bytes to
       access each element for each dimension of the array.
 
-   .. attribute:: size
-
-      The number of bytes in the buffer.  Also available as ``len(view)``.
-
    .. memoryview.suboffsets isn't documented because it only seems useful for C
 
 

Modified: python/branches/py3k/Lib/test/test_memoryview.py
==============================================================================
--- python/branches/py3k/Lib/test/test_memoryview.py	(original)
+++ python/branches/py3k/Lib/test/test_memoryview.py	Wed Sep 10 23:47:03 2008
@@ -146,7 +146,7 @@
         self.assertEquals(m.itemsize, 1)
         self.assertEquals(m.ndim, 1)
         self.assertEquals(m.shape, (6,))
-        self.assertEquals(m.size, 6)
+        self.assertEquals(len(m), 6)
         self.assertEquals(m.strides, (1,))
         self.assertEquals(m.suboffsets, None)
         return m

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Wed Sep 10 23:47:03 2008
@@ -12,6 +12,8 @@
 Core and Builtins
 -----------------
 
+- Issue #3827: memoryview lost its size attribute in favor of using len(view).
+
 - Issue #3813: could not lanch python.exe via symbolic link on cygwin.
 
 - Issue #3705: fix crash when given a non-ascii value on the command line for

Modified: python/branches/py3k/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k/Objects/memoryobject.c	(original)
+++ python/branches/py3k/Objects/memoryobject.c	Wed Sep 10 23:47:03 2008
@@ -370,12 +370,6 @@
 }
 
 static PyObject *
-memory_size_get(PyMemoryViewObject *self)
-{
-        return PyLong_FromSsize_t(self->view.len);
-}
-
-static PyObject *
 memory_readonly_get(PyMemoryViewObject *self)
 {
         return PyBool_FromLong(self->view.readonly);
@@ -393,7 +387,6 @@
         {"shape",	(getter)memory_shape_get,	NULL, NULL},
         {"strides",	(getter)memory_strides_get,	NULL, NULL},
         {"suboffsets",	(getter)memory_suboffsets_get,	NULL, NULL},
-        {"size",	(getter)memory_size_get,	NULL, NULL},
         {"readonly",	(getter)memory_readonly_get,	NULL, NULL},
         {"ndim",	(getter)memory_ndim_get,	NULL, NULL},
         {NULL, NULL, NULL, NULL},


More information about the Python-3000-checkins mailing list