diff options
| author | czgdp1807 <gdp.1807@gmail.com> | 2021-06-05 15:08:40 +0530 |
|---|---|---|
| committer | czgdp1807 <gdp.1807@gmail.com> | 2021-06-05 15:08:40 +0530 |
| commit | 3a3d31b338258c099fa4f2d4e4290b19b2a409b0 (patch) | |
| tree | 8e7939534f5f12ae1d1be3f25e9a23d468f89c50 /numpy/core | |
| parent | 496bd1a84a6a62adf5f8cb48cf7abc7795484531 (diff) | |
| download | numpy-3a3d31b338258c099fa4f2d4e4290b19b2a409b0.tar.gz | |
initial work for supporting never_copy
Diffstat (limited to 'numpy/core')
| -rw-r--r-- | numpy/core/include/numpy/ndarraytypes.h | 2 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/conversion_utils.c | 5 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/conversion_utils.h | 3 | ||||
| -rw-r--r-- | numpy/core/src/multiarray/methods.c | 3 |
4 files changed, 11 insertions, 2 deletions
diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index d1acfdf26..569e6bb34 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -451,6 +451,8 @@ typedef struct { int len; } PyArray_Dims; +typedef enum {IF_NEEDED, ALWAYS, NEVER} PyNpCopyMode_Enum; + typedef struct { /* * Functions to cast to most other standard types diff --git a/numpy/core/src/multiarray/conversion_utils.c b/numpy/core/src/multiarray/conversion_utils.c index 3c4c21ded..50ebea0e5 100644 --- a/numpy/core/src/multiarray/conversion_utils.c +++ b/numpy/core/src/multiarray/conversion_utils.c @@ -162,6 +162,11 @@ PyArray_OptionalIntpConverter(PyObject *obj, PyArray_Dims *seq) return PyArray_IntpConverter(obj, seq); } +NPY_NO_EXPORT int +PyArray_CopyConverter(PyObject *obj, PyNpCopyMode_Enum *copymode) { + return 0; +} + /*NUMPY_API * Get buffer chunk from object * diff --git a/numpy/core/src/multiarray/conversion_utils.h b/numpy/core/src/multiarray/conversion_utils.h index 7d1871c43..d2874aafa 100644 --- a/numpy/core/src/multiarray/conversion_utils.h +++ b/numpy/core/src/multiarray/conversion_utils.h @@ -10,6 +10,9 @@ NPY_NO_EXPORT int PyArray_OptionalIntpConverter(PyObject *obj, PyArray_Dims *seq); NPY_NO_EXPORT int +PyArray_CopyConverter(PyObject *obj, PyNpCopyMode_Enum *copyflag); + +NPY_NO_EXPORT int PyArray_BufferConverter(PyObject *obj, PyArray_Chunk *buf); NPY_NO_EXPORT int diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index 251e527a6..892039508 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -830,13 +830,12 @@ array_astype(PyArrayObject *self, NPY_ORDER order = NPY_KEEPORDER; int forcecopy = 1, subok = 1; NPY_PREPARE_ARGPARSER; - if (npy_parse_arguments("astype", args, len_args, kwnames, "dtype", &PyArray_DescrConverter, &dtype, "|order", &PyArray_OrderConverter, &order, "|casting", &PyArray_CastingConverter, &casting, "|subok", &PyArray_PythonPyIntFromInt, &subok, - "|copy", &PyArray_PythonPyIntFromInt, &forcecopy, + "|copy", &PyArray_CopyConverter, &forcecopy, NULL, NULL, NULL) < 0) { Py_XDECREF(dtype); return NULL; |
