mirror of https://github.com/python/cpython
Issue #15855: added docstrings for memoryview methods and data descriptors.
This commit is contained in:
parent
94dd7cb0c7
commit
397e5c98bc
|
@ -402,14 +402,33 @@ memory_ndim_get(PyMemoryViewObject *self)
|
||||||
return PyLong_FromLong(self->view.ndim);
|
return PyLong_FromLong(self->view.ndim);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyGetSetDef memory_getsetlist[] ={
|
PyDoc_STRVAR(memory_format_doc,
|
||||||
{"format", (getter)memory_format_get, NULL, NULL},
|
"A string containing the format (in struct module style)\n"
|
||||||
{"itemsize", (getter)memory_itemsize_get, NULL, NULL},
|
" for each element in the view.");
|
||||||
{"shape", (getter)memory_shape_get, NULL, NULL},
|
PyDoc_STRVAR(memory_itemsize_doc,
|
||||||
{"strides", (getter)memory_strides_get, NULL, NULL},
|
"The size in bytes of each element of the memoryview.");
|
||||||
{"suboffsets", (getter)memory_suboffsets_get, NULL, NULL},
|
PyDoc_STRVAR(memory_shape_doc,
|
||||||
{"readonly", (getter)memory_readonly_get, NULL, NULL},
|
"A tuple of ndim integers giving the shape of the memory\n"
|
||||||
{"ndim", (getter)memory_ndim_get, NULL, NULL},
|
" as an N-dimensional array.");
|
||||||
|
PyDoc_STRVAR(memory_strides_doc,
|
||||||
|
"A tuple of ndim integers giving the size in bytes to access\n"
|
||||||
|
" each element for each dimension of the array.");
|
||||||
|
PyDoc_STRVAR(memory_suboffsets_doc,
|
||||||
|
"A tuple of integers used internally for PIL-style arrays.");
|
||||||
|
PyDoc_STRVAR(memory_readonly_doc,
|
||||||
|
"A bool indicating whether the memory is read only.");
|
||||||
|
PyDoc_STRVAR(memory_ndim_doc,
|
||||||
|
"An integer indicating how many dimensions of a multi-dimensional\n"
|
||||||
|
" array the memory represents.");
|
||||||
|
|
||||||
|
static PyGetSetDef memory_getsetlist[] = {
|
||||||
|
{"format", (getter)memory_format_get, NULL, memory_format_doc},
|
||||||
|
{"itemsize", (getter)memory_itemsize_get, NULL, memory_itemsize_doc},
|
||||||
|
{"shape", (getter)memory_shape_get, NULL, memory_shape_doc},
|
||||||
|
{"strides", (getter)memory_strides_get, NULL, memory_strides_doc},
|
||||||
|
{"suboffsets", (getter)memory_suboffsets_get, NULL, memory_suboffsets_doc},
|
||||||
|
{"readonly", (getter)memory_readonly_get, NULL, memory_readonly_doc},
|
||||||
|
{"ndim", (getter)memory_ndim_get, NULL, memory_ndim_doc},
|
||||||
{NULL, NULL, NULL, NULL},
|
{NULL, NULL, NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -485,10 +504,23 @@ memory_exit(PyObject *self, PyObject *args)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PyDoc_STRVAR(memory_release_doc,
|
||||||
|
"M.release() -> None\n\
|
||||||
|
\n\
|
||||||
|
Release the underlying buffer exposed by the memoryview object.");
|
||||||
|
PyDoc_STRVAR(memory_tobytes_doc,
|
||||||
|
"M.tobytes() -> bytes\n\
|
||||||
|
\n\
|
||||||
|
Return the data in the buffer as a byte string.");
|
||||||
|
PyDoc_STRVAR(memory_tolist_doc,
|
||||||
|
"M.tolist() -> list\n\
|
||||||
|
\n\
|
||||||
|
Return the data in the buffer as a list of elements.");
|
||||||
|
|
||||||
static PyMethodDef memory_methods[] = {
|
static PyMethodDef memory_methods[] = {
|
||||||
{"release", memory_exit, METH_NOARGS},
|
{"release", memory_exit, METH_NOARGS, memory_release_doc},
|
||||||
{"tobytes", (PyCFunction)memory_tobytes, METH_NOARGS, NULL},
|
{"tobytes", (PyCFunction)memory_tobytes, METH_NOARGS, memory_tobytes_doc},
|
||||||
{"tolist", (PyCFunction)memory_tolist, METH_NOARGS, NULL},
|
{"tolist", (PyCFunction)memory_tolist, METH_NOARGS, memory_tolist_doc},
|
||||||
{"__enter__", memory_enter, METH_NOARGS},
|
{"__enter__", memory_enter, METH_NOARGS},
|
||||||
{"__exit__", memory_exit, METH_VARARGS},
|
{"__exit__", memory_exit, METH_VARARGS},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
|
|
Loading…
Reference in New Issue