Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5cc7ef0

Browse filesBrowse files
authored
Merge pull request #20315 from seberg/remove-py37-c-switches
MAINT: Remove Python <3.8 support from C
2 parents f52acb5 + 3dcbecc commit 5cc7ef0
Copy full SHA for 5cc7ef0

File tree

5 files changed

+4
-90
lines changed
Filter options

5 files changed

+4
-90
lines changed

‎numpy/core/include/numpy/ufuncobject.h

Copy file name to clipboardExpand all lines: numpy/core/include/numpy/ufuncobject.h
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,8 @@ typedef struct _tagPyUFuncObject {
173173
* but this was never implemented. (This is also why the above
174174
* selector is called the "legacy" selector.)
175175
*/
176-
#if PY_VERSION_HEX >= 0x03080000
177176
vectorcallfunc vectorcall;
178-
#else
179-
void *reserved2;
180-
#endif
177+
181178
/* Was previously the `PyUFunc_MaskedInnerLoopSelectionFunc` */
182179
void *_always_null_previously_masked_innerloop_selector;
183180

‎numpy/core/src/multiarray/compiled_base.c

Copy file name to clipboardExpand all lines: numpy/core/src/multiarray/compiled_base.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ arr_add_docstring(PyObject *NPY_UNUSED(dummy), PyObject *args)
13931393
{
13941394
PyObject *obj;
13951395
PyObject *str;
1396-
#if PY_VERSION_HEX >= 0x030700A2 && (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM > 0x07030300)
1396+
#if !defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM > 0x07030300
13971397
const char *docstr;
13981398
#else
13991399
char *docstr;

‎numpy/core/src/multiarray/methods.c

Copy file name to clipboardExpand all lines: numpy/core/src/multiarray/methods.c
-14Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,22 +1821,8 @@ array_reduce_ex_picklebuffer(PyArrayObject *self, int protocol)
18211821

18221822
descr = PyArray_DESCR(self);
18231823

1824-
/* if the python version is below 3.8, the pickle module does not provide
1825-
* built-in support for protocol 5. We try importing the pickle5
1826-
* backport instead */
1827-
#if PY_VERSION_HEX >= 0x03080000
18281824
/* we expect protocol 5 to be available in Python 3.8 */
18291825
pickle_module = PyImport_ImportModule("pickle");
1830-
#else
1831-
pickle_module = PyImport_ImportModule("pickle5");
1832-
if (pickle_module == NULL) {
1833-
/* for protocol 5, raise a clear ImportError if pickle5 is not found
1834-
*/
1835-
PyErr_SetString(PyExc_ImportError, "Using pickle protocol 5 "
1836-
"requires the pickle5 module for Python >=3.6 and <3.8");
1837-
return NULL;
1838-
}
1839-
#endif
18401826
if (pickle_module == NULL){
18411827
return NULL;
18421828
}

‎numpy/core/src/umath/ufunc_object.c

Copy file name to clipboardExpand all lines: numpy/core/src/umath/ufunc_object.c
+1-69Lines changed: 1 addition & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4925,65 +4925,6 @@ ufunc_generic_fastcall(PyUFuncObject *ufunc,
49254925
}
49264926

49274927

4928-
/*
4929-
* TODO: The implementation below can be replaced with PyVectorcall_Call
4930-
* when available (should be Python 3.8+).
4931-
*/
4932-
static PyObject *
4933-
ufunc_generic_call(
4934-
PyUFuncObject *ufunc, PyObject *args, PyObject *kwds)
4935-
{
4936-
Py_ssize_t len_args = PyTuple_GET_SIZE(args);
4937-
/*
4938-
* Wrapper for tp_call to tp_fastcall, to support both on older versions
4939-
* of Python. (and generally simplifying support of both versions in the
4940-
* same codebase.
4941-
*/
4942-
if (kwds == NULL) {
4943-
return ufunc_generic_fastcall(ufunc,
4944-
PySequence_Fast_ITEMS(args), len_args, NULL, NPY_FALSE);
4945-
}
4946-
4947-
PyObject *new_args[NPY_MAXARGS];
4948-
Py_ssize_t len_kwds = PyDict_Size(kwds);
4949-
4950-
if (NPY_UNLIKELY(len_args + len_kwds > NPY_MAXARGS)) {
4951-
/*
4952-
* We do not have enough scratch-space, so we have to abort;
4953-
* In practice this error should not be seen by users.
4954-
*/
4955-
PyErr_Format(PyExc_ValueError,
4956-
"%s() takes from %d to %d positional arguments but "
4957-
"%zd were given",
4958-
ufunc_get_name_cstr(ufunc) , ufunc->nin, ufunc->nargs, len_args);
4959-
return NULL;
4960-
}
4961-
4962-
/* Copy args into the scratch space */
4963-
for (Py_ssize_t i = 0; i < len_args; i++) {
4964-
new_args[i] = PyTuple_GET_ITEM(args, i);
4965-
}
4966-
4967-
PyObject *kwnames = PyTuple_New(len_kwds);
4968-
4969-
PyObject *key, *value;
4970-
Py_ssize_t pos = 0;
4971-
Py_ssize_t i = 0;
4972-
while (PyDict_Next(kwds, &pos, &key, &value)) {
4973-
Py_INCREF(key);
4974-
PyTuple_SET_ITEM(kwnames, i, key);
4975-
new_args[i + len_args] = value;
4976-
i++;
4977-
}
4978-
4979-
PyObject *res = ufunc_generic_fastcall(ufunc,
4980-
new_args, len_args, kwnames, NPY_FALSE);
4981-
Py_DECREF(kwnames);
4982-
return res;
4983-
}
4984-
4985-
4986-
#if PY_VERSION_HEX >= 0x03080000
49874928
/*
49884929
* Implement vectorcallfunc which should be defined with Python 3.8+.
49894930
* In principle this could be backported, but the speed gain seems moderate
@@ -5001,7 +4942,6 @@ ufunc_generic_vectorcall(PyObject *ufunc,
50014942
return ufunc_generic_fastcall((PyUFuncObject *)ufunc,
50024943
args, PyVectorcall_NARGS(len_args), kwnames, NPY_FALSE);
50034944
}
5004-
#endif /* PY_VERSION_HEX >= 0x03080000 */
50054945

50064946

50074947
NPY_NO_EXPORT PyObject *
@@ -5178,11 +5118,7 @@ PyUFunc_FromFuncAndDataAndSignatureAndIdentity(PyUFuncGenericFunction *func, voi
51785118
ufunc->core_dim_flags = NULL;
51795119
ufunc->userloops = NULL;
51805120
ufunc->ptr = NULL;
5181-
#if PY_VERSION_HEX >= 0x03080000
51825121
ufunc->vectorcall = &ufunc_generic_vectorcall;
5183-
#else
5184-
ufunc->reserved2 = NULL;
5185-
#endif
51865122
ufunc->reserved1 = 0;
51875123
ufunc->iter_flags = 0;
51885124

@@ -6437,19 +6373,15 @@ NPY_NO_EXPORT PyTypeObject PyUFunc_Type = {
64376373
.tp_basicsize = sizeof(PyUFuncObject),
64386374
.tp_dealloc = (destructor)ufunc_dealloc,
64396375
.tp_repr = (reprfunc)ufunc_repr,
6440-
.tp_call = (ternaryfunc)ufunc_generic_call,
6376+
.tp_call = &PyVectorcall_Call,
64416377
.tp_str = (reprfunc)ufunc_repr,
64426378
.tp_flags = Py_TPFLAGS_DEFAULT |
6443-
#if PY_VERSION_HEX >= 0x03080000
64446379
_Py_TPFLAGS_HAVE_VECTORCALL |
6445-
#endif
64466380
Py_TPFLAGS_HAVE_GC,
64476381
.tp_traverse = (traverseproc)ufunc_traverse,
64486382
.tp_methods = ufunc_methods,
64496383
.tp_getset = ufunc_getset,
6450-
#if PY_VERSION_HEX >= 0x03080000
64516384
.tp_vectorcall_offset = offsetof(PyUFuncObject, vectorcall),
6452-
#endif
64536385
};
64546386

64556387
/* End of code for ufunc objects */

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030

3131
# Python supported version checks. Keep right after stdlib imports to ensure we
3232
# get a sensible error for older Python versions
33-
# This needs to be changed to 3.8 for 1.22 release, but 3.7 is needed for LGTM.
34-
if sys.version_info[:2] < (3, 7):
33+
if sys.version_info[:2] < (3, 8):
3534
raise RuntimeError("Python version >= 3.8 required.")
3635

3736

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.