Skip to content

Commit 9fee0f8

Browse files
committed
DOC: Slightly extend to docs to note that we assume no-copy buffer protocol
1 parent dea4055 commit 9fee0f8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

numpy/_globals.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ class _CopyMode(enum.Enum):
106106
- NEVER: This means that the deep copy will never be taken.
107107
If a copy cannot be avoided then a `ValueError` will be
108108
raised.
109+
110+
Note that the buffer-protocol could in theory do copies. NumPy currently
111+
assumes an object exporting the buffer protocol will never do this.
109112
"""
110113

111114
ALWAYS = True

numpy/core/include/numpy/ndarraytypes.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
868868

869869
/*
870870
* Always copy the array. Returned arrays are always CONTIGUOUS,
871-
* ALIGNED, and WRITEABLE.
871+
* ALIGNED, and WRITEABLE. See also: NPY_ARRAY_ENSURENOCOPY = 0x4000.
872872
*
873873
* This flag may be requested in constructor functions.
874874
*/
@@ -937,6 +937,11 @@ typedef int (PyArray_FinalizeFunc)(PyArrayObject *, PyObject *);
937937
#define NPY_ARRAY_UPDATEIFCOPY 0x1000 /* Deprecated in 1.14 */
938938
#define NPY_ARRAY_WRITEBACKIFCOPY 0x2000
939939

940+
/*
941+
* No copy may be made while converting from an object/array (result is a view)
942+
*
943+
* This flag may be requested in constructor functions.
944+
*/
940945
#define NPY_ARRAY_ENSURENOCOPY 0x4000
941946

942947
/*

0 commit comments

Comments
 (0)