8000 MAINT: Make `needs_api` declaration local in most cases as per review · numpy/numpy@71e33fd · GitHub
[go: up one dir, main page]

Skip to content

Commit 71e33fd

Browse files
committed
MAINT: Make needs_api declaration local in most cases as per review
1 parent b406c8f commit 71e33fd

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

numpy/_core/src/multiarray/ctors.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,7 +2696,6 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
26962696

26972697
npy_intp dst_count, src_count, count;
26982698
npy_intp dst_size, src_size;
2699-
int needs_api;
27002699

27012700
NPY_BEGIN_THREADS_DEF;
27022701

@@ -2787,7 +2786,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
27872786
return -1;
27882787
}
27892788
/* No need to worry about API use in unbuffered iterator */
2790-
needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
2789+
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
27912790
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
27922791
npy_clear_floatstatus_barrier((char *)src_iter);
27932792
}

numpy/_core/src/multiarray/einsum.c.src

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,6 @@ PyArray_EinsteinSum(char *subscripts, npy_intp nop,
11281128
char **dataptr;
11291129
npy_intp *stride;
11301130
npy_intp *countptr;
1131-
int needs_api;
11321131
NPY_BEGIN_THREADS_DEF;
11331132

11341133
iternext = NpyIter_GetIterNext(iter, NULL);
@@ -1139,7 +1138,7 @@ PyArray_EinsteinSum(char *subscripts, npy_intp nop,
11391138
stride = NpyIter_GetInnerStrideArray(iter);
11401139
countptr = NpyIter_GetInnerLoopSizePtr(iter);
11411140
/* IterationNeedsAPI additionally checks for object dtype here. */
1142-
needs_api = NpyIter_IterationNeedsAPI(iter);
1141+
int needs_api = NpyIter_IterationNeedsAPI(iter);
11431142
if (!needs_api) {
11441143
NPY_BEGIN_THREADS_THRESHOLDED(NpyIter_GetIterSize(iter));
11451144
}

numpy/_core/src/umath/ufunc_object.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,7 +1695,6 @@ PyUFunc_GeneralizedFunctionInternal(PyUFuncObject *ufunc,
16951695
int i, j, idim, nop;
16961696
const char *ufunc_name;
16971697
int retval;
1698-
int needs_api = 0;
16991698

17001699
/* Use remapped axes for generalized ufunc */
17011700
int broadcast_ndim, iter_ndim;
@@ -2093,7 +2092,7 @@ PyUFunc_GeneralizedFunctionInternal(PyUFuncObject *ufunc,
20932092
goto fail;
20942093
}
20952094
flags = PyArrayMethod_COMBINED_FLAGS(flags, NpyIter_GetTransferFlags(iter));
2096-
needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
2095+
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
20972096

20982097
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
20992098
/* Start with the floating-point exception flags cleared */
@@ -2575,7 +2574,7 @@ PyUFunc_Accumulate(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *out,
25752574
int *op_axes[2] = {op_axes_arrays[0], op_axes_arrays[1]};
25762575
npy_uint32 op_flags[2];
25772576
int idim, ndim;
2578-
int needs_api, need_outer_iterator;
2577+
int need_outer_iterator;
25792578
int res = 0;
25802579

25812580
NPY_cast_info copy_info;
@@ -2762,7 +2761,7 @@ PyUFunc_Accumulate(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *out,
27622761
flags = PyArrayMethod_COMBINED_FLAGS(flags, NpyIter_GetTransferFlags(iter));
27632762
}
27642763

2765-
needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
2764+
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
27662765
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
27672766
/* Start with the floating-point exception flags cleared */
27682767
npy_clear_floatstatus_barrier((char*)&iter);
@@ -2983,7 +2982,7 @@ PyUFunc_Reduceat(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *ind,
29832982
op_axes_arrays[2]};
29842983
npy_uint32 op_flags[3];
29852984
int idim, ndim;
2986-
int needs_api, need_outer_iterator = 0;
2985+
int need_outer_iterator = 0;
29872986

29882987
int res = 0;
29892988

@@ -3186,7 +3185,7 @@ PyUFunc_Reduceat(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *ind,
31863185
flags = PyArrayMethod_COMBINED_FLAGS(flags, NpyIter_GetTransferFlags(iter));
31873186
}
31883187

3189-
needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
3188+
int needs_api = (flags & NPY_METH_REQUIRES_PYAPI) != 0;
31903189
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
31913190
/* Start with the floating-point exception flags cleared */
31923191
npy_clear_floatstatus_barrier((char*)&iter);

0 commit comments

Comments
 (0)
0