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

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 ago
Right Patch Set: Created 2 years, 12 months 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice( 163 PyAPI_FUNC(PyObject*) _PyStack_AsTupleSlice(
164 PyObject **stack, 164 PyObject **stack,
165 Py_ssize_t nargs, 165 Py_ssize_t nargs,
166 Py_ssize_t start, 166 Py_ssize_t start,
167 Py_ssize_t end); 167 Py_ssize_t end);
168 168
169 /* Convert keyword arguments from the (stack, kwnames) format to a Python 169 /* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
170 dictionary. 170 format to a Python dictionary ("kwargs" dict).
171 171
172 kwnames must only contains str strings, no subclass, and all keys must be 172 The type of kwnames keys is not checked. The final function getting
173 unique. kwnames is not checked, usually these checks are done before or 173 arguments is reponsible to check if all keys are strings, for example using
174 later calling _PyStack_AsDict(). For example, _PyArg_ParseStackAndKeywords() raises an 174 PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
175 error if a key is not a string. */ 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. */
176 PyAPI_FUNC(PyObject *) _PyStack_AsDict( 179 PyAPI_FUNC(PyObject *) _PyStack_AsDict(
177 PyObject **values, 180 PyObject **values,
178 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);
179 195
180 /* Suggested size (number of positional arguments) for arrays of PyObject* 196 /* Suggested size (number of positional arguments) for arrays of PyObject*
181 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
182 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
183 _PyObject_FastCall() family. 199 _PyObject_FastCall() family.
184 200
185 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
186 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
187 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
188 40 bytes on the stack. */ 204 40 bytes on the stack. */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 PyObject *obj, 251 PyObject *obj,
236 PyObject *args, 252 PyObject *args,
237 PyObject *kwargs); 253 PyObject *kwargs);
238 254
239 PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(PyObject *func, 255 PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(PyObject *func,
240 PyObject *obj, 256 PyObject *obj,
241 PyObject **args, 257 PyObject **args,
242 Py_ssize_t nargs, 258 Py_ssize_t nargs,
243 PyObject *kwnames); 259 PyObject *kwnames);
244 260
261 PyAPI_FUNC(int) _PyStack_UnpackDict(PyObject **args, Py_ssize_t nargs,
262 PyObject *kwargs,
263 PyObject ***p_stack, PyObject **p_kwnames);
264
245 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable, 265 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,
246 PyObject *result, 266 PyObject *result,
247 const char *where); 267 const char *where);
248 #endif /* Py_LIMITED_API */ 268 #endif /* Py_LIMITED_API */
249 269
250 270
251 #ifdef Py_BUILD_CORE 271 #ifdef Py_BUILD_CORE
252 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(
253 PyObject *self, 275 PyObject *self,
254 fastternaryfunc fastcall, 276 fastternaryfunc fastcall,
255 PyObject **args, 277 PyObject **args,
256 Py_ssize_t nargs, 278 Py_ssize_t nargs,
257 PyObject *kwargs); 279 PyObject *kwargs);
258 #endif 280 #endif
259 281
260 282
261 /* Call a callable Python object 'callable', with arguments given by the 283 /* Call a callable Python object 'callable', with arguments given by the
262 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
1082 const Py_ssize_t *shape); 1104 const Py_ssize_t *shape);
1083 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,
1084 const Py_ssize_t *shape); 1106 const Py_ssize_t *shape);
1085 #endif /* !Py_LIMITED_API */ 1107 #endif /* !Py_LIMITED_API */
1086 1108
1087 1109
1088 #ifdef __cplusplus 1110 #ifdef __cplusplus
1089 } 1111 }
1090 #endif 1112 #endif
1091 #endif /* Py_ABSTRACTOBJECT_H */ 1113 #endif /* Py_ABSTRACTOBJECT_H */
LEFTRIGHT

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