mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
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.
This commit is contained in:
parent
45ec5b99ae
commit
a15e260b70
17 changed files with 72 additions and 30 deletions
|
@ -1,6 +1,7 @@
|
|||
/* List object implementation */
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_abstract.h" // _PyIndex_Check()
|
||||
#include "pycore_object.h"
|
||||
#include "pycore_pystate.h"
|
||||
#include "pycore_tupleobject.h"
|
||||
|
@ -2800,7 +2801,7 @@ static PySequenceMethods list_as_sequence = {
|
|||
static PyObject *
|
||||
list_subscript(PyListObject* self, PyObject* item)
|
||||
{
|
||||
if (PyIndex_Check(item)) {
|
||||
if (_PyIndex_Check(item)) {
|
||||
Py_ssize_t i;
|
||||
i = PyNumber_AsSsize_t(item, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred())
|
||||
|
@ -2855,7 +2856,7 @@ list_subscript(PyListObject* self, PyObject* item)
|
|||
static int
|
||||
list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||
{
|
||||
if (PyIndex_Check(item)) {
|
||||
if (_PyIndex_Check(item)) {
|
||||
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
|
||||
if (i == -1 && PyErr_Occurred())
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue