summaryrefslogtreecommitdiffstats
path: root/Objects/memoryobject.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-04-08 00:01:56 (GMT)
committerGitHub <noreply@github.com>2020-04-08 00:01:56 (GMT)
commita15e260b708a98edaba86a2aa663c3f6b2abc964 (patch)
treeac80e678c0266db42f8264a1fccfdeb1f58f6a17 /Objects/memoryobject.c
parent45ec5b99aefa54552947049086e87ec01bc2fc9a (diff)
downloadcpython-a15e260b708a98edaba86a2aa663c3f6b2abc964.zip
cpython-a15e260b708a98edaba86a2aa663c3f6b2abc964.tar.gz
cpython-a15e260b708a98edaba86a2aa663c3f6b2abc964.tar.bz2
bpo-40170: Add _PyIndex_Check() internal function (GH-19426)
Add _PyIndex_Check() function to the internal C API: fast inlined verson of PyIndex_Check(). Add Include/internal/pycore_abstract.h header file. Replace PyIndex_Check() with _PyIndex_Check() in C files of Objects and Python subdirectories.
Diffstat (limited to 'Objects/memoryobject.c')
-rw-r--r--Objects/memoryobject.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index 7f9c900..da06338 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -11,6 +11,7 @@
*/
#include "Python.h"
+#include "pycore_abstract.h" // _PyIndex_Check()
#include "pycore_object.h"
#include "pycore_pymem.h"
#include "pycore_pystate.h"
@@ -2421,8 +2422,9 @@ is_multiindex(PyObject *key)
size = PyTuple_GET_SIZE(key);
for (i = 0; i < size; i++) {
PyObject *x = PyTuple_GET_ITEM(key, i);
- if (!PyIndex_Check(x))
+ if (!_PyIndex_Check(x)) {
return 0;
+ }
}
return 1;
}
@@ -2459,7 +2461,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
}
}
- if (PyIndex_Check(key)) {
+ if (_PyIndex_Check(key)) {
Py_ssize_t index;
index = PyNumber_AsSsize_t(key, PyExc_IndexError);
if (index == -1 && PyErr_Occurred())
@@ -2530,7 +2532,7 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
}
}
- if (PyIndex_Check(key)) {
+ if (_PyIndex_Check(key)) {
Py_ssize_t index;
if (1 < view->ndim) {
PyErr_SetString(PyExc_NotImplementedError,