Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Commit 07db3e9

Browse files
authored
gh-87613: Use AC vectorcall for slice() (#159471)
]
1 parent 974a7f7 commit 07db3e9

3 files changed

Lines changed: 101 additions & 11 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Speed up calling :class:`slice` by adding a vectorcall implementation of the constructor generated by Argument Clinic. Patch by Pieter Eendebak.

‎Objects/clinic/sliceobject.c.h‎

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Objects/sliceobject.c‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ this type and there is exactly one in existence.
2121
#include "pycore_object.h" // _PyObject_GC_TRACK()
2222
#include "pycore_sliceobject.h" // _PyBuildSlice_ConsumeRefs
2323

24+
#include "clinic/sliceobject.c.h"
25+
26+
/*[clinic input]
27+
class slice "PySliceObject *" "&PySlice_Type"
28+
[clinic start generated code]*/
29+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=857b514967456ef4]*/
30+
2431

2532
#define _PySlice_CAST(op) _Py_CAST(PySliceObject*, (op))
2633

@@ -308,19 +315,22 @@ PySlice_GetIndicesEx(PyObject *_r, Py_ssize_t length,
308315
return 0;
309316
}
310317

311-
static PyObject *
312-
slice_new(PyTypeObject *type, PyObject *args, PyObject *kw)
313-
{
314-
PyObject *start, *stop, *step;
318+
/*[clinic input]
319+
@classmethod
320+
@vectorcall
321+
slice.__new__ as slice_new
315322
316-
start = stop = step = NULL;
317-
318-
if (!_PyArg_NoKeywords("slice", kw))
319-
return NULL;
320-
321-
if (!PyArg_UnpackTuple(args, "slice", 1, 3, &start, &stop, &step))
322-
return NULL;
323+
start: object
324+
stop: object(c_default="NULL") = None
325+
step: object(c_default="NULL") = None
326+
/
327+
[clinic start generated code]*/
323328

329+
static PyObject *
330+
slice_new_impl(PyTypeObject *type, PyObject *start, PyObject *stop,
331+
PyObject *step)
332+
/*[clinic end generated code: output=35a6e86397efb677 input=cf5c572a0d2caa22]*/
333+
{
324334
/* This swapping of stop and start is to maintain similarity with
325335
range(). */
326336
if (stop == NULL) {
@@ -702,4 +712,5 @@ PyTypeObject PySlice_Type = {
702712
0, /* tp_init */
703713
0, /* tp_alloc */
704714
slice_new, /* tp_new */
715+
.tp_vectorcall = slice_vectorcall,
705716
};

0 commit comments

Comments
 (0)