#3560: cleanup C memoryview API · pythoncapi/cpython@ee58fa4 · GitHub
Skip to content

Commit ee58fa4

Browse files
committed
python#3560: cleanup C memoryview API
1 parent fd03645 commit ee58fa4

5 files changed

Lines changed: 30 additions & 18 deletions

File tree

Include/memoryobject.h

Lines changed: 19 additions & 13 deletions

Misc/NEWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ What's new in Python 3.0b3?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #3560: clean up the new C PyMemoryView API so that naming is
16+
internally consistent; add macros PyMemoryView_GET_BASE() and
17+
PyMemoryView_GET_BUFFER() to access useful properties of a memory views
18+
without relying on a particular implementation; remove the ill-named
19+
PyMemoryView() function (PyMemoryView_GET_BUFFER() can be used instead).
20+
1521
- Issue #1819: function calls with several named parameters are now on
1622
average 35% faster (as measured by pybench).
1723

Modules/_json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
264264
if (PyBuffer_FillInfo(&info, NULL, &buf[end], next - end, 1, 0) < 0) {
265265
goto bail;
266266
}
267-
strchunk = PyMemoryView_FromMemory(&info);
267+
strchunk = PyMemoryView_FromBuffer(&info);
268268
if (strchunk == NULL) {
269269
goto bail;
270270
}

Objects/memoryobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PyDoc_STRVAR(memory_doc,
2929
Create a new memoryview object which references the given object.");
3030

3131
PyObject *
32-
PyMemoryView_FromMemory(Py_buffer *info)
32+
PyMemoryView_FromBuffer(Py_buffer *info)
3333
{
3434
PyMemoryViewObject *mview;
3535

@@ -231,7 +231,7 @@ PyMemoryView_GetContiguous(PyObject *obj, int buffertype, char fort)
231231
mem = PyObject_New(PyMemoryViewObject, &PyMemoryView_Type);
232232
if (mem == NULL) return NULL;
233233

234-
view = &PyMemoryView(mem);
234+
view = &mem->view;
235235
flags = PyBUF_FULL_RO;
236236
switch(buffertype) {
237237
case PyBUF_WRITE:
@@ -534,7 +534,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
534534
/* XXX: This needs to be fixed so it
535535
actually returns a sub-view
536536
*/
537-
return PyMemoryView_FromMemory(&newview);
537+
return PyMemoryView_FromBuffer(&newview);
538538
}
539539
}
540540

Objects/unicodeobject.c

Lines changed: 1 addition & 1 deletion

0 commit comments

Comments
 (0)