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

Side by Side Diff: Include/abstract.h

Issue 29259: Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects
Patch Set: Created 3 years, 4 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:
View unified diff | Download patch
« no previous file with comments | « no previous file | Include/methodobject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 /* Convert keyword arguments from the (stack, kwnames) format to a Python 169 /* Convert keyword arguments from the (stack, kwnames) format to a Python
170 dictionary. 170 dictionary.
171 171
172 kwnames must only contains str strings, no subclass, and all keys must be 172 kwnames must only contains str strings, no subclass, and all keys must be
173 unique. kwnames is not checked, usually these checks are done before or 173 unique. kwnames is not checked, usually these checks are done before or
174 later calling _PyStack_AsDict(). For example, _PyArg_ParseStackAndKeywords() raises an 174 later calling _PyStack_AsDict(). For example, _PyArg_ParseStackAndKeywords() raises an
175 error if a key is not a string. */ 175 error if a key is not a string. */
176 PyAPI_FUNC(PyObject *) _PyStack_AsDict( 176 PyAPI_FUNC(PyObject *) _PyStack_AsDict(
177 PyObject **values, 177 PyObject **values,
178 PyObject *kwnames); 178 PyObject *kwnames);
179
180 /* Convert (args, nargs, kwargs: dict) into a (stack, nargs, kwnames: tuple).
181
182 Return 0 on success, raise an exception and return -1 on error.
183
184 Write the new stack into *p_stack. If *p_stack is differen than args, it
185 must be released by PyMem_Free().
186
187 The stack uses borrowed references.
188
189 The type of keyword keys is not checked, these checks should be done
190 later (ex: _PyArg_ParseStackAndKeywords). */
191 PyAPI_FUNC(int) _PyStack_UnpackDict(
192 PyObject **args,
193 Py_ssize_t nargs,
194 PyObject *kwargs,
195 PyObject ***p_stack,
196 PyObject **p_kwnames,
197 PyObject *func);
198 179
199 /* Suggested size (number of positional arguments) for arrays of PyObject* 180 /* Suggested size (number of positional arguments) for arrays of PyObject*
200 allocated on a C stack to avoid allocating memory on the heap memory. Such 181 allocated on a C stack to avoid allocating memory on the heap memory. Such
201 array is used to pass positional arguments to call functions of the 182 array is used to pass positional arguments to call functions of the
202 _PyObject_FastCall() family. 183 _PyObject_FastCall() family.
203 184
204 The size is chosen to not abuse the C stack and so limit the risk of stack 185 The size is chosen to not abuse the C stack and so limit the risk of stack
205 overflow. The size is also chosen to allow using the small stack for most 186 overflow. The size is also chosen to allow using the small stack for most
206 function calls of the Python standard library. On 64-bit CPU, it allocates 187 function calls of the Python standard library. On 64-bit CPU, it allocates
207 40 bytes on the stack. */ 188 40 bytes on the stack. */
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 _PyObject_FastCallDict((func), (args), (nargs), NULL) 228 _PyObject_FastCallDict((func), (args), (nargs), NULL)
248 229
249 #define _PyObject_CallNoArg(func) \ 230 #define _PyObject_CallNoArg(func) \
250 _PyObject_FastCallDict((func), NULL, 0, NULL) 231 _PyObject_FastCallDict((func), NULL, 0, NULL)
251 232
252 PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend( 233 PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
253 PyObject *callable, 234 PyObject *callable,
254 PyObject *obj, 235 PyObject *obj,
255 PyObject *args, 236 PyObject *args,
256 PyObject *kwargs); 237 PyObject *kwargs);
238
239 PyAPI_FUNC(PyObject *) _PyObject_FastCall_Prepend(PyObject *func,
240 PyObject *obj,
241 PyObject **args,
242 Py_ssize_t nargs,
243 PyObject *kwnames);
257 244
258 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable, 245 PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *callable,
259 PyObject *result, 246 PyObject *result,
260 const char *where); 247 const char *where);
261 #endif /* Py_LIMITED_API */ 248 #endif /* Py_LIMITED_API */
262 249
263 250
251 #ifdef Py_BUILD_CORE
252 PyAPI_FUNC(PyObject *) _Py_FastCall_FromArgs(
253 PyObject *self,
254 fastternaryfunc fastcall,
255 PyObject **args,
256 Py_ssize_t nargs,
257 PyObject *kwargs);
258 #endif
259
260
264 /* Call a callable Python object 'callable', with arguments given by the 261 /* Call a callable Python object 'callable', with arguments given by the
265 tuple 'args'. If no arguments are needed, then 'args' can be *NULL*. 262 tuple 'args'. If no arguments are needed, then 'args' can be *NULL*.
266 263
267 Returns the result of the call on success, or *NULL* on failure. 264 Returns the result of the call on success, or *NULL* on failure.
268 265
269 This is the equivalent of the Python expression: 266 This is the equivalent of the Python expression:
270 callable(*args). */ 267 callable(*args). */
271 PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable, 268 PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
272 PyObject *args); 269 PyObject *args);
273 270
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 const Py_ssize_t *shape); 1082 const Py_ssize_t *shape);
1086 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, 1083 PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
1087 const Py_ssize_t *shape); 1084 const Py_ssize_t *shape);
1088 #endif /* !Py_LIMITED_API */ 1085 #endif /* !Py_LIMITED_API */
1089 1086
1090 1087
1091 #ifdef __cplusplus 1088 #ifdef __cplusplus
1092 } 1089 }
1093 #endif 1090 #endif
1094 #endif /* Py_ABSTRACTOBJECT_H */ 1091 #endif /* Py_ABSTRACTOBJECT_H */
OLDNEW
« no previous file with comments | « no previous file | Include/methodobject.h » ('j') | no next file with comments »

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