summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2021-06-23 17:03:32 -0500
committerSebastian Berg <sebastian@sipsolutions.net>2021-06-23 17:05:27 -0500
commit604ba56384026a3c951c5f8f86157cf6ec1a5ed7 (patch)
tree919ff3d623f40efd6e1a429a2e665e463ea5d9fa
parent46761358acde44a7a4945d9a94f81fb3cac1f474 (diff)
downloadnumpy-604ba56384026a3c951c5f8f86157cf6ec1a5ed7.tar.gz
MAINT: Clean up multiarray interned strings
This removes unused interned strings from multiarray and modifies the pattern to the one used in `umathmodule.c` also. (It may be that we even had this pattern here as well, but that it was lost in a merge conflict.)
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c39
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.h7
2 files changed, 10 insertions, 36 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index f7c3ea093..b1d0fe756 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -4606,16 +4606,9 @@ set_flaginfo(PyObject *d)
return;
}
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_array = NULL;
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_array_prepare = NULL;
NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_array_wrap = NULL;
NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_array_finalize = NULL;
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_ufunc = NULL;
NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_implementation = NULL;
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_order = NULL;
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_copy = NULL;
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_dtype = NULL;
-NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_ndmin = NULL;
NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_axis1 = NULL;
NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_axis2 = NULL;
NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_like = NULL;
@@ -4624,27 +4617,15 @@ NPY_VISIBILITY_HIDDEN PyObject * npy_ma_str_numpy = NULL;
static int
intern_strings(void)
{
- npy_ma_str_array = PyUnicode_InternFromString("__array__");
- npy_ma_str_array_prepare = PyUnicode_InternFromString("__array_prepare__");
- npy_ma_str_array_wrap = PyUnicode_InternFromString("__array_wrap__");
- npy_ma_str_array_finalize = PyUnicode_InternFromString("__array_finalize__");
- npy_ma_str_ufunc = PyUnicode_InternFromString("__array_ufunc__");
- npy_ma_str_implementation = PyUnicode_InternFromString("_implementation");
- npy_ma_str_order = PyUnicode_InternFromString("order");
- npy_ma_str_copy = PyUnicode_InternFromString("copy");
- npy_ma_str_dtype = PyUnicode_InternFromString("dtype");
- npy_ma_str_ndmin = PyUnicode_InternFromString("ndmin");
- npy_ma_str_axis1 = PyUnicode_InternFromString("axis1");
- npy_ma_str_axis2 = PyUnicode_InternFromString("axis2");
- npy_ma_str_like = PyUnicode_InternFromString("like");
- npy_ma_str_numpy = PyUnicode_InternFromString("numpy");
-
- return npy_ma_str_array && npy_ma_str_array_prepare &&
- npy_ma_str_array_wrap && npy_ma_str_array_finalize &&
- npy_ma_str_ufunc && npy_ma_str_implementation &&
- npy_ma_str_order && npy_ma_str_copy && npy_ma_str_dtype &&
- npy_ma_str_ndmin && npy_ma_str_axis1 && npy_ma_str_axis2 &&
- npy_ma_str_like && npy_ma_str_numpy;
+ if (!(npy_ma_str_array_wrap = PyUnicode_InternFromString("__array_wrap__"))) return -1;
+ if (!(npy_ma_str_array_finalize = PyUnicode_InternFromString("__array_finalize__"))) return -1;
+ if (!(npy_ma_str_implementation = PyUnicode_InternFromString("_implementation"))) return -1;
+ if (!(npy_ma_str_axis1 = PyUnicode_InternFromString("axis1"))) return -1;
+ if (!(npy_ma_str_axis2 = PyUnicode_InternFromString("axis2"))) return -1;
+ if (!(npy_ma_str_like = PyUnicode_InternFromString("like"))) return -1;
+ if (!(npy_ma_str_numpy = PyUnicode_InternFromString("numpy"))) return -1;
+
+ return 0;
}
static struct PyModuleDef moduledef = {
@@ -4876,7 +4857,7 @@ PyMODINIT_FUNC PyInit__multiarray_umath(void) {
goto err;
}
- if (!intern_strings()) {
+ if (intern_strings() < 0) {
goto err;
}
diff --git a/numpy/core/src/multiarray/multiarraymodule.h b/numpy/core/src/multiarray/multiarraymodule.h
index d3ee3337c..4cdb6ef72 100644
--- a/numpy/core/src/multiarray/multiarraymodule.h
+++ b/numpy/core/src/multiarray/multiarraymodule.h
@@ -1,16 +1,9 @@
#ifndef _NPY_MULTIARRAY_H_
#define _NPY_MULTIARRAY_H_
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array;
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array_prepare;
NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array_wrap;
NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_array_finalize;
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_ufunc;
NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_implementation;
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_order;
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_copy;
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_dtype;
-NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_ndmin;
NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_axis1;
NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_axis2;
NPY_VISIBILITY_HIDDEN extern PyObject * npy_ma_str_like;