Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Delta Between Two Patch Sets: Include/abstract.h

Issue 29259: Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects
Left Patch Set: Created 3 years, 1 month ago
Right Patch Set: Created 3 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Include/descrobject.h » ('j') | Objects/abstract.c » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* Abstract Object Interface (many thanks to Jim Fulton) */ 1 /* Abstract Object Interface (many thanks to Jim Fulton) */
2 2
3 #ifndef Py_ABSTRACTOBJECT_H 3 #ifndef Py_ABSTRACTOBJECT_H
4 #define Py_ABSTRACTOBJECT_H 4 #define Py_ABSTRACTOBJECT_H
5 #ifdef __cplusplus 5 #ifdef __cplusplus
6 extern "C" { 6 extern "C" {
7 #endif 7 #endif
8 8
9 /* === Object Protocol ================================================== */ 9 /* === Object Protocol ================================================== */
10 10
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 This is the equivalent of the Python expression: 153 This is the equivalent of the Python expression:
154 callable(*args, **kwargs). */ 154 callable(*args, **kwargs). */
155 PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable, 155 PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
156 PyObject *args, PyObject *kwargs); 156 PyObject *args, PyObject *kwargs);
157 157
158 #ifndef Py_LIMITED_API 158 #ifndef Py_LIMITED_API
159 PyAPI_FUNC(PyObject*) _PyStack_AsTuple( 159 PyAPI_FUNC(PyObject*) _PyStack_AsTuple(
160 PyObject **stack, 160 PyObject **stack,
161 Py_ssize_t nargs); 161 Py_ssize_t nargs);
162 162
163 /* Convert keyword arguments from the (stack, kwnames) format to a Python 163 PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
164 dictionary. 164 PyObject **stack,
165 165 Py_ssize_t nargs,
166 kwnames must only contains str strings, no subclass, and all keys must be 166 Py_ssize_t start,
167 unique. kwnames is not checked, usually these checks are done before or 167 Py_ssize_t end);
168 later calling _PyStack_AsDict(). For example, _PyArg_ParseStack() raises an 168
169 error if a key is not a string. */ 169 /* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
170 format to a Python dictionary ("kwargs" dict).
171
172 The type of kwnames keys is not checked. The final function getting
173 arguments is reponsible to check if all keys are strings, for example using
174 PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
175
176 Duplicate keys are merged using the last value. If duplicate keys must raise
177 an exception, the caller is responsible to implement an explicit keys on
178 kwnames. */
170 PyAPI_FUNC(PyObject *) _PyStack_AsDict( 179 PyAPI_FUNC(PyObject *) _PyStack_AsDict(
171 PyObject **values, 180 PyObject **values,
172 PyObject *kwnames); 181 PyObject *kwnames);
182
183 /* Convert FASTCALL (stack, nargs, kwnames) arguments
184 to (args: tuple, kwargs: dict) format.
185
186 Return 0 on success. Raise an exception and return -1 on error.
187
188 The function combines _PyStack_AsTuple() and _PyStack_AsDict(). */
189 PyAPI_FUNC(int) _PyStack_AsTupleAndDict(
190 PyObject **stack,
191 Py_ssize_t nargs,
192 PyObject *kwnames,
193 PyObject **p_args,
194 PyObject **p_kwargs);
173 195
174 /* Suggested size (number of positional arguments) for arrays of PyObject* 196 /* Suggested size (number of positional arguments) for arrays of PyObject*
175 allocated on a C stack to avoid allocating memory on the heap memory. Such 197 allocated on a C stack to avoid allocating memory on the heap memory. Such
176 array is used to pass positional arguments to call functions of the 198 array is used to pass positional arguments to call functions of the
177 _PyObject_FastCall() family. 199 _PyObject_FastCall() family.
178 200
179 The size is chosen to not abuse the C stack and so limit the risk of stack 201 The size is chosen to not abuse the C stack and so limit the risk of stack
180 overflow. The size is also chosen to allow using the small stack for most 202 overflow. The size is also chosen to allow using the small stack for most
181 function calls of the Python standard library. On 64-bit CPU, it allocates 203 function calls of the Python standard library. On 64-bit CPU, it allocates
182 40 bytes on the stack. */ 204 40 bytes on the stack. */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 PyObject *obj, 251 PyObject *obj,
230 PyObject *args, 252 PyObject *args,
231 PyObject *kwargs); 253 PyObject *kwargs);
232 254
233 PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(PyObject *func, 255 PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(PyObject *func,
234 PyObject *obj, 256 PyObject *obj,
235 PyObject **args, 257 PyObject **args,
236 Py_ssize_t nargs, 258 Py_ssize_t nargs,
237 PyObject *kwnames); 259 PyObject *kwnames);
238 260
261 PyAPI_FUNC(int) _PyStack_UnpackDict(PyObject **args, Py_ssize_t nargs,
262 PyObject *kwargs,
263 PyObject ***p_stack, PyObject **p_kwnames);
264
239 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable, 265 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,
240 PyObject *result, 266 PyObject *result,
241 const char *where); 267 const char *where);
242 #endif /* Py_LIMITED_API */ 268 #endif /* Py_LIMITED_API */
243 269
244 270
245 #ifdef Py_BUILD_CORE 271 #ifdef Py_BUILD_CORE
246 PyAPI_FUNC(PyObject *) _Py_FastCall_FromArgs( 272 /* Low-level function to call a C function using FASTCALL calling convention.
273 Don't check the result: the caller must check _Py_CheckFunctionResult(). */
274 PyAPI_FUNC(PyObject *) _Py_RawFastCallDict(
247 PyObject *self, 275 PyObject *self,
248 fastternaryfunc fastcall, 276 fastternaryfunc fastcall,
249 PyObject **args, 277 PyObject **args,
250 Py_ssize_t nargs, 278 Py_ssize_t nargs,
251 PyObject *kwargs); 279 PyObject *kwargs);
252 #endif 280 #endif
253 281
254 282
255 /* Call a callable Python object 'callable', with arguments given by the 283 /* Call a callable Python object 'callable', with arguments given by the
256 tuple 'args'. If no arguments are needed, then 'args' can be *NULL*. 284 tuple 'args'. If no arguments are needed, then 'args' can be *NULL*.
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 const Py_ssize_t *shape); 1104 const Py_ssize_t *shape);
1077 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, 1105 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
1078 const Py_ssize_t *shape); 1106 const Py_ssize_t *shape);
1079 #endif /* !Py_LIMITED_API */ 1107 #endif /* !Py_LIMITED_API */
1080 1108
1081 1109
1082 #ifdef __cplusplus 1110 #ifdef __cplusplus
1083 } 1111 }
1084 #endif 1112 #endif
1085 #endif /* Py_ABSTRACTOBJECT_H */ 1113 #endif /* Py_ABSTRACTOBJECT_H */
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+