@@ -58,72 +58,13 @@ PyVectorcall_NARGS(size_t n)
58
58
return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET ;
59
59
}
60
60
61
- static inline vectorcallfunc
62
- PyVectorcall_Function (PyObject * callable )
63
- {
64
- PyTypeObject * tp ;
65
- Py_ssize_t offset ;
66
- vectorcallfunc ptr ;
67
-
68
- assert (callable != NULL );
69
- tp = Py_TYPE (callable );
70
- if (!PyType_HasFeature (tp , Py_TPFLAGS_HAVE_VECTORCALL )) {
71
- return NULL ;
72
- }
73
- assert (PyCallable_Check (callable ));
74
-
75
- offset = tp -> tp_vectorcall_offset ;
76
- assert (offset > 0 );
77
- memcpy (& ptr , (char * ) callable + offset , sizeof (ptr ));
78
- return ptr ;
79
- }
80
-
81
- /* Call the callable object 'callable' with the "vectorcall" calling
82
- convention.
83
-
84
- args is a C array for positional arguments.
85
-
86
- nargsf is the number of positional arguments plus optionally the flag
87
- PY_VECTORCALL_ARGUMENTS_OFFSET which means that the caller is allowed to
88
- modify args[-1].
89
-
90
- kwnames is a tuple of keyword names. The values of the keyword arguments
91
- are stored in "args" after the positional arguments (note that the number
92
- of keyword arguments does not change nargsf). kwnames can also be NULL if
93
- there are no keyword arguments.
61
+ PyAPI_FUNC (vectorcallfunc ) PyVectorcall_Function (PyObject * callable );
94
62
95
- keywords must only contain strings and all keys must be unique.
96
-
97
- Return the result on success. Raise an exception and return NULL on
98
- error. */
99
- static inline PyObject *
100
- _PyObject_VectorcallTstate (PyThreadState * tstate , PyObject * callable ,
101
- PyObject * const * args , size_t nargsf ,
102
- PyObject * kwnames )
103
- {
104
- vectorcallfunc func ;
105
- PyObject * res ;
106
-
107
- assert (kwnames == NULL || PyTuple_Check (kwnames ));
108
- assert (args != NULL || PyVectorcall_NARGS (nargsf ) == 0 );
109
-
110
- func = PyVectorcall_Function (callable );
111
- if (func == NULL ) {
112
- Py_ssize_t nargs = PyVectorcall_NARGS (nargsf );
113
- return _PyObject_MakeTpCall (tstate , callable , args , nargs , kwnames );
114
- }
115
- res = func (callable , args , nargsf , kwnames );
116
- return _Py_CheckFunctionResult (tstate , callable , res , NULL );
117
- }
118
-
119
- static inline PyObject *
120
- PyObject_Vectorcall (PyObject * callable , PyObject * const * args ,
121
- size_t nargsf , PyObject * kwnames )
122
- {
123
- PyThreadState * tstate = PyThreadState_Get ();
124
- return _PyObject_VectorcallTstate (tstate , callable ,
125
- args , nargsf , kwnames );
126
- }
63
+ PyAPI_FUNC (PyObject * ) PyObject_Vectorcall (
64
+ PyObject * callable ,
65
+ PyObject * const * args ,
66
+ size_t nargsf ,
67
+ PyObject * kwnames );
127
68
128
69
// Backwards compatibility aliases for API that was provisional in Python 3.8
129
70
#define _PyObject_Vectorcall PyObject_Vectorcall
@@ -146,35 +87,13 @@ PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
146
87
"tuple" and keyword arguments "dict". "dict" may also be NULL */
147
88
PyAPI_FUNC (PyObject * ) PyVectorcall_Call (PyObject * callable , PyObject * tuple , PyObject * dict );
148
89
149
- static inline PyObject *
150
- _PyObject_FastCallTstate (PyThreadState * tstate , PyObject * func , PyObject * const * args , Py_ssize_t nargs )
151
- {
152
- return _PyObject_VectorcallTstate (tstate , func , args , (size_t )nargs , NULL );
153
- }
154
-
155
- /* Same as PyObject_Vectorcall except without keyword arguments */
156
- static inline PyObject *
157
- _PyObject_FastCall (PyObject * func , PyObject * const * args , Py_ssize_t nargs )
158
- {
159
- PyThreadState * tstate = PyThreadState_Get ();
160
- return _PyObject_FastCallTstate (tstate , func , args , nargs );
161
- }
162
-
163
- static inline PyObject *
164
- PyObject_CallOneArg (PyObject * func , PyObject * arg )
165
- {
166
- PyObject * _args [2 ];
167
- PyObject * * args ;
168
- PyThreadState * tstate ;
169
- size_t nargsf ;
90
+ // Same as PyObject_Vectorcall(), except without keyword arguments
91
+ PyAPI_FUNC (PyObject * ) _PyObject_FastCall (
92
+ PyObject * func ,
93
+ PyObject * const * args ,
94
+ Py_ssize_t nargs );
170
95
171
- assert (arg != NULL );
172
- args = _args + 1 ; // For PY_VECTORCALL_ARGUMENTS_OFFSET
173
- args [0 ] = arg ;
174
- tstate = PyThreadState_Get ();
175
- nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET ;
176
- return _PyObject_VectorcallTstate (tstate , func , args , nargsf , NULL );
177
- }
96
+ PyAPI_FUNC (PyObject * ) PyObject_CallOneArg (PyObject * func , PyObject * arg );
178
97
179
98
PyAPI_FUNC (PyObject * ) PyObject_VectorcallMethod (
180
99
PyObject * name , PyObject * const * args ,
0 commit comments