diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2020-10-03 17:16:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-03 17:16:56 (GMT) |
commit | d646e91f5c4f4b76f96494103d440ed0b6257425 (patch) | |
tree | a95ff2dea63de61ff328c226684a1893040174fb /Objects/enumobject.c | |
parent | 3fe614893742faee3c64e6d974e11329a496424f (diff) | |
download | cpython-d646e91f5c4f4b76f96494103d440ed0b6257425.zip cpython-d646e91f5c4f4b76f96494103d440ed0b6257425.tar.gz cpython-d646e91f5c4f4b76f96494103d440ed0b6257425.tar.bz2 |
bpo-41922: Use PEP 590 vectorcall to speed up reversed() (GH-22523)
Diffstat (limited to 'Objects/enumobject.c')
-rw-r--r-- | Objects/enumobject.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Objects/enumobject.c b/Objects/enumobject.c index 4a83bb4..9d8449b 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -314,6 +314,24 @@ reversed_new_impl(PyTypeObject *type, PyObject *seq) return (PyObject *)ro; } +static PyObject * +reversed_vectorcall(PyObject *type, PyObject * const*args, + size_t nargsf, PyObject *kwnames) +{ + assert(PyType_Check(type)); + + if (!_PyArg_NoKwnames("reversed", kwnames)) { + return NULL; + } + + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + if (!_PyArg_CheckPositional("reversed", nargs, 1, 1)) { + return NULL; + } + + return reversed_new_impl((PyTypeObject *)type, args[0]); +} + static void reversed_dealloc(reversedobject *ro) { @@ -445,4 +463,5 @@ PyTypeObject PyReversed_Type = { PyType_GenericAlloc, /* tp_alloc */ reversed_new, /* tp_new */ PyObject_GC_Del, /* tp_free */ + .tp_vectorcall = (vectorcallfunc)reversed_vectorcall, }; |