diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1044,6 +1044,11 @@ return -1; } +PyDoc_STRVAR(memory_release_doc, +"M.release() -> None\n\ +\n\ +Release the underlying buffer exposed by the memoryview object."); + static PyObject * memory_release(PyMemoryViewObject *self, PyObject *noargs) { @@ -1304,6 +1309,12 @@ All casts must result in views that will have the exact byte size of the original input. Otherwise, an error is raised. */ + +PyDoc_STRVAR(memory_cast_doc, +"M.cast(format[, shape]) -> memoryview\n\ +\n\ +Cast a memoryview to a new format or shape."); + static PyObject * memory_cast(PyMemoryViewObject *self, PyObject *args, PyObject *kwds) { @@ -2061,6 +2072,11 @@ /* Return a list representation of the memoryview. Currently only buffers with native format strings are supported. */ +PyDoc_STRVAR(memory_tolist_doc, +"M.tobytes() -> list\n\ +\n\ +Return the data in the buffer as a list of elements."); + static PyObject * memory_tolist(PyMemoryViewObject *mv, PyObject *noargs) { @@ -2087,6 +2103,11 @@ } } +PyDoc_STRVAR(memory_tobytes_doc, +"M.tobytes() -> bytes\n\ +\n\ +Return the data in the buffer as a bytestring."); + static PyObject * memory_tobytes(PyMemoryViewObject *self, PyObject *dummy) { @@ -2879,10 +2900,10 @@ static PyMethodDef memory_methods[] = { - {"release", (PyCFunction)memory_release, METH_NOARGS, NULL}, - {"tobytes", (PyCFunction)memory_tobytes, METH_NOARGS, NULL}, - {"tolist", (PyCFunction)memory_tolist, METH_NOARGS, NULL}, - {"cast", (PyCFunction)memory_cast, METH_VARARGS|METH_KEYWORDS, NULL}, + {"release", (PyCFunction)memory_release, METH_NOARGS, memory_release_doc}, + {"tobytes", (PyCFunction)memory_tobytes, METH_NOARGS, memory_tobytes_doc}, + {"tolist", (PyCFunction)memory_tolist, METH_NOARGS, memory_tolist_doc}, + {"cast", (PyCFunction)memory_cast, METH_VARARGS|METH_KEYWORDS, memory_cast_doc}, {"__enter__", memory_enter, METH_NOARGS, NULL}, {"__exit__", memory_exit, METH_VARARGS, NULL}, {NULL, NULL}