Skip to content

Commit 559bb6a

Browse files
committed
Rename _PyObject_FastCall() to _PyObject_FastCallDict()
Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict()
1 parent c98afb7 commit 559bb6a

File tree

12 files changed

+39
-30
lines changed

12 files changed

+39
-30
lines changed

Include/abstract.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,18 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
279279
280280
Return the result on success. Raise an exception on return NULL on
281281
error. */
282-
PyAPI_FUNC(PyObject *) _PyObject_FastCall(PyObject *func,
283-
PyObject **args, int nargs,
284-
PyObject *kwargs);
282+
PyAPI_FUNC(PyObject *) _PyObject_FastCallDict(PyObject *func,
283+
PyObject **args, int nargs,
284+
PyObject *kwargs);
285+
286+
#define _PyObject_FastCall(func, args, nargs) \
287+
_PyObject_FastCallDict((func), (args), (nargs), NULL)
288+
289+
#define _PyObject_CallNoArg(func) \
290+
_PyObject_FastCall((func), NULL, 0)
291+
292+
#define _PyObject_CallArg1(func, arg) \
293+
_PyObject_FastCall((func), &(arg), 1)
285294

286295
PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func,
287296
PyObject *result,
@@ -291,7 +300,7 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
291300
/*
292301
Call a callable Python object, callable_object, with
293302
arguments and keywords arguments. The 'args' argument can not be
294-
NULL, but the 'kw' argument can be NULL.
303+
NULL.
295304
*/
296305

297306
PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object,

Modules/_elementtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ deepcopy(PyObject *object, PyObject *memo)
858858

859859
stack[0] = object;
860860
stack[1] = memo;
861-
return _PyObject_FastCall(st->deepcopy_obj, stack, 2, NULL);
861+
return _PyObject_FastCall(st->deepcopy_obj, stack, 2);
862862
}
863863

864864

Modules/_functoolsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ keyobject_richcompare(PyObject *ko, PyObject *other, int op)
492492
*/
493493
stack[0] = x;
494494
stack[1] = y;
495-
res = _PyObject_FastCall(compare, stack, 2, NULL);
495+
res = _PyObject_FastCall(compare, stack, 2);
496496
if (res == NULL) {
497497
return NULL;
498498
}

Modules/_pickle.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ _Pickle_FastCall(PyObject *func, PyObject *obj)
357357
significantly reduced the number of function calls we do. Thus, the
358358
benefits became marginal at best. */
359359

360-
result = _PyObject_FastCall(func, &obj, 1, NULL);
360+
result = _PyObject_CallArg1(func, obj);
361361
Py_DECREF(obj);
362362
return result;
363363
}
@@ -1151,7 +1151,7 @@ _Unpickler_ReadFromFile(UnpicklerObject *self, Py_ssize_t n)
11511151
return -1;
11521152

11531153
if (n == READ_WHOLE_LINE) {
1154-
data = _PyObject_FastCall(self->readline, NULL, 0, NULL);
1154+
data = _PyObject_CallNoArg(self->readline);
11551155
}
11561156
else {
11571157
PyObject *len;
@@ -3948,7 +3948,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
39483948
/* Check for a __reduce__ method. */
39493949
reduce_func = _PyObject_GetAttrId(obj, &PyId___reduce__);
39503950
if (reduce_func != NULL) {
3951-
reduce_value = _PyObject_FastCall(reduce_func, NULL, 0, NULL);
3951+
reduce_value = _PyObject_CallNoArg(reduce_func);
39523952
}
39533953
else {
39543954
PyErr_Format(st->PicklingError,

Modules/_sre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ pattern_subx(PatternObject* self, PyObject* ptemplate, PyObject* string,
11571157
match = pattern_new_match(self, &state, 1);
11581158
if (!match)
11591159
goto error;
1160-
item = _PyObject_FastCall(filter, &match, 1, NULL);
1160+
item = _PyObject_CallArg1(filter, match);
11611161
Py_DECREF(match);
11621162
if (!item)
11631163
goto error;

Objects/abstract.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,12 +2255,12 @@ _PyStack_AsTuple(PyObject **stack, Py_ssize_t nargs)
22552255
}
22562256

22572257
PyObject *
2258-
_PyObject_FastCall(PyObject *func, PyObject **args, int nargs, PyObject *kwargs)
2258+
_PyObject_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs)
22592259
{
22602260
ternaryfunc call;
22612261
PyObject *result = NULL;
22622262

2263-
/* _PyObject_FastCall() must not be called with an exception set,
2263+
/* _PyObject_FastCallDict() must not be called with an exception set,
22642264
because it may clear it (directly or indirectly) and so the
22652265
caller loses its exception */
22662266
assert(!PyErr_Occurred());
@@ -2318,7 +2318,7 @@ call_function_tail(PyObject *callable, PyObject *args)
23182318
assert(args != NULL);
23192319

23202320
if (!PyTuple_Check(args)) {
2321-
result = _PyObject_FastCall(callable, &args, 1, NULL);
2321+
result = _PyObject_CallArg1(callable, args);
23222322
}
23232323
else {
23242324
result = PyObject_Call(callable, args, NULL);
@@ -2338,7 +2338,7 @@ PyObject_CallFunction(PyObject *callable, const char *format, ...)
23382338
}
23392339

23402340
if (!format || !*format) {
2341-
return _PyObject_FastCall(callable, NULL, 0, NULL);
2341+
return _PyObject_CallNoArg(callable);
23422342
}
23432343

23442344
va_start(va, format);
@@ -2364,7 +2364,7 @@ _PyObject_CallFunction_SizeT(PyObject *callable, const char *format, ...)
23642364
}
23652365

23662366
if (!format || !*format) {
2367-
return _PyObject_FastCall(callable, NULL, 0, NULL);
2367+
return _PyObject_CallNoArg(callable);
23682368
}
23692369

23702370
va_start(va, format);
@@ -2392,7 +2392,7 @@ callmethod(PyObject* func, const char *format, va_list va, int is_size_t)
23922392
}
23932393

23942394
if (!format || !*format) {
2395-
return _PyObject_FastCall(func, NULL, 0, NULL);
2395+
return _PyObject_CallNoArg(func);
23962396
}
23972397

23982398
if (is_size_t) {

Objects/fileobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags)
146146
Py_DECREF(writer);
147147
return -1;
148148
}
149-
result = _PyObject_FastCall(writer, &value, 1, NULL);
149+
result = _PyObject_CallArg1(writer, value);
150150
Py_DECREF(value);
151151
Py_DECREF(writer);
152152
if (result == NULL)

Objects/iterobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ calliter_iternext(calliterobject *it)
214214
return NULL;
215215
}
216216

217-
result = _PyObject_FastCall(it->it_callable, NULL, 0, NULL);
217+
result = _PyObject_CallNoArg(it->it_callable);
218218
if (result != NULL) {
219219
int ok;
220220

Objects/typeobject.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ call_method(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
14501450
Py_DECREF(args);
14511451
}
14521452
else {
1453-
retval = _PyObject_FastCall(func, NULL, 0, NULL);
1453+
retval = _PyObject_CallNoArg(func);
14541454
}
14551455

14561456
Py_DECREF(func);
@@ -1490,7 +1490,7 @@ call_maybe(PyObject *o, _Py_Identifier *nameid, const char *format, ...)
14901490
Py_DECREF(args);
14911491
}
14921492
else {
1493-
retval = _PyObject_FastCall(func, NULL, 0, NULL);
1493+
retval = _PyObject_CallNoArg(func);
14941494
}
14951495

14961496
Py_DECREF(func);
@@ -5834,7 +5834,7 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
58345834
goto error;
58355835
}
58365836

5837-
retval = _PyObject_FastCall(func, &ival, 1, NULL);
5837+
retval = _PyObject_CallArg1(func, ival);
58385838
Py_DECREF(func);
58395839
Py_DECREF(ival);
58405840
return retval;
@@ -5875,7 +5875,7 @@ slot_sq_contains(PyObject *self, PyObject *value)
58755875
return -1;
58765876
}
58775877
if (func != NULL) {
5878-
res = _PyObject_FastCall(func, &value, 1, NULL);
5878+
res = _PyObject_CallArg1(func, value);
58795879
Py_DECREF(func);
58805880
if (res != NULL) {
58815881
result = PyObject_IsTrue(res);
@@ -5967,7 +5967,7 @@ slot_nb_bool(PyObject *self)
59675967
using_len = 1;
59685968
}
59695969

5970-
value = _PyObject_FastCall(func, NULL, 0, NULL);
5970+
value = _PyObject_CallNoArg(func);
59715971
if (value == NULL) {
59725972
goto error;
59735973
}
@@ -6245,7 +6245,7 @@ slot_tp_richcompare(PyObject *self, PyObject *other, int op)
62456245
PyErr_Clear();
62466246
Py_RETURN_NOTIMPLEMENTED;
62476247
}
6248-
res = _PyObject_FastCall(func, &other, 1, NULL);
6248+
res = _PyObject_CallArg1(func, other);
62496249
Py_DECREF(func);
62506250
return res;
62516251
}
@@ -6266,7 +6266,7 @@ slot_tp_iter(PyObject *self)
62666266
}
62676267

62686268
if (func != NULL) {
6269-
res = _PyObject_FastCall(func, NULL, 0, NULL);
6269+
res = _PyObject_CallNoArg(func);
62706270
Py_DECREF(func);
62716271
return res;
62726272
}

Python/ceval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,7 +4593,7 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
45934593

45944594
if (args == NULL) {
45954595
if (kwargs == NULL) {
4596-
return _PyObject_FastCall(func, NULL, 0, 0);
4596+
return _PyObject_CallNoArg(func);
45974597
}
45984598

45994599
args = PyTuple_New(0);
@@ -5298,7 +5298,7 @@ import_name(PyFrameObject *f, PyObject *name, PyObject *fromlist, PyObject *leve
52985298
stack[2] = f->f_locals == NULL ? Py_None : f->f_locals;
52995299
stack[3] = fromlist;
53005300
stack[4] = level;
5301-
res = _PyObject_FastCall(import_func, stack, 5, NULL);
5301+
res = _PyObject_FastCall(import_func, stack, 5);
53025302
Py_DECREF(import_func);
53035303
return res;
53045304
}

0 commit comments

Comments
 (0)