Skip to content

Commit c62fa9a

Browse files
committed
revert to fastcall
1 parent afd8a5b commit c62fa9a

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

  • Modules/_testlimitedcapi

Modules/_testlimitedcapi/set.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
#if !defined(Py_GIL_DISABLED) && !defined(Py_LIMITED_API)
2+
// Need limited C API for METH_FASTCALL
3+
#define Py_LIMITED_API 0x030d0000
4+
#endif
5+
16
#include "parts.h"
27
#include "util.h"
38

9+
410
static PyObject *
511
set_check(PyObject *self, PyObject *obj)
612
{
@@ -202,12 +208,15 @@ test_set_contains_does_not_convert_unhashable_key(PyObject *self, PyObject *Py_U
202208

203209
// Interface to PySet_Add, returning the set
204210
static PyObject *
205-
pyset_add(PyObject *self, PyObject *args)
211+
pyset_add(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
206212
{
207-
PyObject *set, *item;
208-
if (!PyArg_ParseTuple(args, "OO", &set, &item)) {
213+
if (nargs != 2) {
214+
PyErr_SetString(PyExc_TypeError,
215+
"pyset_add requires exactly 2 arguments");
209216
return NULL;
210217
}
218+
PyObject *set = args[0];
219+
PyObject *item = args[1];
211220

212221
int return_value = PySet_Add(set, item);
213222
if (return_value < 0) {
@@ -237,7 +246,7 @@ static PyMethodDef test_methods[] = {
237246
{"test_frozenset_add_in_capi", test_frozenset_add_in_capi, METH_NOARGS},
238247
{"test_set_contains_does_not_convert_unhashable_key",
239248
test_set_contains_does_not_convert_unhashable_key, METH_NOARGS},
240-
{"pyset_add", pyset_add, METH_VARARGS},
249+
{"pyset_add", _PyCFunction_CAST(pyset_add), METH_FASTCALL},
241250

242251
{NULL},
243252
};

0 commit comments

Comments
 (0)