summaryrefslogtreecommitdiffstats
path: root/Objects/methodobject.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-37340: Remove PyMethod_ClearFreeList() and PyCFunction_ClearFreeList() ↵Victor Stinner2019-11-201-15/+0
| | | | | | | | (GH-17284) Remove PyMethod_ClearFreeList() and PyCFunction_ClearFreeList() functions: the free lists of bound method objects have been removed. Remove also _PyMethod_Fini() and _PyCFunction_Fini() functions.
* bpo-37645: add new function _PyObject_FunctionStr() (GH-14890)Jeroen Demeyer2019-11-051-17/+20
| | | | | | | | | | | | Additional note: the `method_check_args` function in `Objects/descrobject.c` is written in such a way that it applies to all kinds of descriptors. In particular, a future re-implementation of `wrapper_descriptor` could use that code. CC @vstinner @encukou https://bugs.python.org/issue37645 Automerge-Triggered-By: @encukou
* bpo-38644: Pass tstate to _Py_CheckFunctionResult() (GH-17050)Victor Stinner2019-11-051-4/+7
| | | | | * Add tstate parameter to _Py_CheckFunctionResult() * Add _PyErr_FormatFromCauseTstate() * Replace PyErr_XXX(...) with _PyErr_XXX(state, ...)
* bpo-38644: Pass tstate to Py_EnterRecursiveCall() (GH-16997)Victor Stinner2019-11-041-22/+28
| | | | | | | | | | | | | * Add _Py_EnterRecursiveCall() and _Py_LeaveRecursiveCall() which require a tstate argument. * Pass tstate to _Py_MakeRecCheck() and _Py_CheckRecursiveCall(). * Convert Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() macros to static inline functions. _PyThreadState_GET() is the most efficient way to get the tstate, and so using it with _Py_EnterRecursiveCall() and _Py_LeaveRecursiveCall() should be a little bit more efficient than using Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() which use the "slower" PyThreadState_GET().
* bpo-37151: remove special case for PyCFunction from PyObject_Call (GH-14684)Jeroen Demeyer2019-09-111-1/+36
| | | | | | | bpo-37151: remove special case for PyCFunction from PyObject_Call Alse, make the undocumented function PyCFunction_Call an alias of PyObject_Call and deprecate it.
* Make PyXXX_Fini() functions private (GH-15531)Victor Stinner2019-08-261-1/+1
| | | | | For example, rename PyTuple_Fini() to _PyTuple_Fini(). These functions are only declared in the internal C API.
* bpo-37340: remove free_list for bound method objects (GH-14232)Inada Naoki2019-07-261-47/+6
|
* bpo-36974: separate vectorcall functions for each calling convention (GH-13781)Jeroen Demeyer2019-07-051-8/+157
|
* bpo-36974: tp_print -> tp_vectorcall_offset and tp_reserved -> tp_as_async ↵Jeroen Demeyer2019-05-311-1/+1
| | | | | | | | | (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
* bpo-36974: rename _FastCallKeywords -> _Vectorcall (GH-13653)Jeroen Demeyer2019-05-301-1/+1
|
* bpo-36974: implement PEP 590 (GH-13185)Jeroen Demeyer2019-05-291-2/+11
| | | | | Co-authored-by: Jeroen Demeyer <J.Demeyer@UGent.be> Co-authored-by: Mark Shannon <mark@hotpy.org>
* bpo-35444: Unify and optimize the helper for getting a builtin object. ↵Serhiy Storchaka2018-12-111-5/+2
| | | | | | | | (GH-11047) This speeds up pickling of some iterators. This fixes also error handling in pickling methods when fail to look up builtin "getattr".
* bpo-35059: PyObject_INIT() casts to PyObject* (GH-10674)Victor Stinner2018-11-231-1/+1
| | | | | | PyObject_INIT() and PyObject_INIT_VAR() now cast their first argument to PyObject*, as done in Python 3.7. Revert partially commit b4435e20a92af474f117b78b98ddc6f515363af5.
* bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner2018-11-211-0/+1
| | | | Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-2/+2
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-2/+2
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* bpo-35059: Convert PyObject_INIT() to function (GH-10077)Victor Stinner2018-10-261-1/+1
| | | | | * Convert PyObject_INIT() and PyObject_INIT_VAR() macros to static inline functions. * Fix usage of these functions: cast to PyObject* or PyVarObject*.
* closes bpo-34646: Remove PyAPI_* macros from declarations. (GH-9218)Benjamin Peterson2018-09-121-1/+1
|
* bpo-1617161: Make the hash and equality of methods not depending on the ↵Serhiy Storchaka2018-07-311-9/+1
| | | | | | | | | | | value of self. (GH-7848) * The hash of BuiltinMethodType instances no longer depends on the hash of __self__. It depends now on the hash of id(__self__). * The hash and equality of ModuleType and MethodWrapperType instances no longer depend on the hash and equality of __self__. They depend now on the hash and equality of id(__self__). * MethodWrapperType instances no longer support ordering.
* bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. ↵Siddhesh Poyarekar2018-04-291-1/+1
| | | | | | | | | (GH-6030) METH_NOARGS functions need only a single argument but they are cast into a PyCFunction, which takes two arguments. This triggers an invalid function cast warning in gcc8 due to the argument mismatch. Fix this by adding a dummy unused argument.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-0/+2
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* bpo-29524: Add Objects/call.c file (#12)Victor Stinner2017-02-121-323/+0
| | | | | | | | | * Move all functions to call objects in a new Objects/call.c file. * Rename fast_function() to _PyFunction_FastCallKeywords(). * Copy null_error() from Objects/abstract.c * Inline type_error() in call.c to not have to copy it, it was only called once. * Export _PyEval_EvalCodeWithName() since it is now called from call.c.
* Backed out changeset f23fa1f7b68fVictor Stinner2017-02-101-0/+323
| | | | | Sorry, I didn't want to push this change before the review :-( I was pushing a change into the 2.7 branch.
* Issue #29465: Add Objects/call.c fileVictor Stinner2017-02-101-323/+0
| | | | | | | | | | * Move all functions to call objects in a new Objects/call.c file. * Rename fast_function() to _PyFunction_FastCallKeywords(). * Copy null_error() from Objects/abstract.c * Inline type_error() in call.c to not have to copy it, it was only called once. * Export _PyEval_EvalCodeWithName() since it is now called from call.c.
* Fix PyCFunction_Call() performance issueVictor Stinner2017-02-091-4/+50
| | | | | | | Issue #29259, #29465: PyCFunction_Call() doesn't create anymore a redundant tuple to pass positional arguments for METH_VARARGS. Add a new cfunction_call() subfunction.
* Issue #29306: Fix usage of Py_EnterRecursiveCall()Victor Stinner2017-02-081-25/+36
| | | | | | | * *PyCFunction_*Call*() functions now call Py_EnterRecursiveCall(). * PyObject_Call() now calls directly _PyFunction_FastCallDict() and PyCFunction_Call() to avoid calling Py_EnterRecursiveCall() twice per function call
* Issue #29263: LOAD_METHOD support for C methodsINADA Naoki2017-02-021-23/+30
| | | | Calling builtin method is at most 10% faster.
* Cleanup _PyMethodDef_RawFastCallDict()Victor Stinner2017-01-181-11/+9
| | | | | | Issue #29259: use a different case for METH_VARARGS and METH_VARARGS|METH_KEYWORDS to avoid testing again flags to decide if keywords should be checked or not.
* Rephrase !PyErr_Occurred() comment: may=>canVictor Stinner2017-01-181-1/+1
| | | | Issue #29259.
* PyCFunction_Call() now calls _PyCFunction_FastCallDict()Victor Stinner2017-01-181-70/+5
| | | | | | | | | | Issue #29259. We had 3 versions of similar code: * PyCFunction_Call() * _PyCFunction_FastCallDict() * _PyCFunction_FastCallKeywords() PyCFunction_Call() now calls _PyCFunction_FastCallDict() to factorize the code.
* Fix _PyMethodDef_RawFastCallDict() argument parsingVictor Stinner2017-01-181-14/+16
| | | | | | | | | Issue #29259: * Move also the !PyErr_Occurred() assertion to the top, similar to other functions. * Fix also comment/error messages: the function was renamed to _PyMethodDef_RawFastCallDict()
* Optimize methoddescr_call(): avoid temporary PyCFunctionVictor Stinner2017-01-181-15/+24
| | | | | | Issue #29259, #29263. methoddescr_call() creates a PyCFunction object, call it and the destroy it. Add a new _PyMethodDef_RawFastCallDict() method to avoid the temporary PyCFunction object.
* Remove unused func parameter of _PyStack_UnpackDict()Victor Stinner2017-01-181-2/+1
| | | | Issue #29259.
* _PyStack_UnpackDict() now returns -1 on errorVictor Stinner2017-01-171-2/+2
| | | | | Issue #29286. Change _PyStack_UnpackDict() prototype to be able to notify of failure when args is NULL.
* Optimize _PyCFunction_FastCallKeywords()Victor Stinner2017-01-161-36/+131
| | | | | | | | | | | | | | Issue #29259: Write fast path in _PyCFunction_FastCallKeywords() for METH_FASTCALL, avoid the creation of a temporary dictionary for keyword arguments. Cleanup also _PyCFunction_FastCallDict(): * Don't dereference func before checking that it's not NULL * Move code to raise the "no keyword argument" exception into a new no_keyword_error label. Update python-gdb.py for the change.
* Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka2016-12-161-4/+5
| | | | dict.
* Fix warning in _PyCFunction_FastCallKeywords()Victor Stinner2016-09-121-2/+1
| | | | Issue #28105.
* Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict()Victor Stinner2016-09-121-0/+5
| | | | Issue #27213.
* Revert change f860b7a775c5Victor Stinner2016-09-121-1/+1
| | | | | Revert change "Issue #27213: Reintroduce checks in _PyStack_AsDict()", pushed by mistake.
* ssue #27213: Reintroduce checks in _PyStack_AsDict()Victor Stinner2016-09-121-1/+1
|
* Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.Serhiy Storchaka2016-09-111-1/+1
| | | | | | | | | | | * BUILD_TUPLE_UNPACK and BUILD_MAP_UNPACK_WITH_CALL no longer generated with single tuple or dict. * Restored more informative error messages for incorrect var-positional and var-keyword arguments. * Removed code duplications in _PyEval_EvalCodeWithName(). * Removed redundant runtime checks and parameters in _PyStack_AsDict(). * Added a workaround and enabled previously disabled test in test_traceback. * Removed dead code from the dis module.
* Add METH_FASTCALL calling conventionVictor Stinner2016-09-101-0/+24
| | | | | | | | | | | Issue #27810: Add a new calling convention for C functions: PyObject* func(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames); Where args is a C array of positional arguments followed by values of keyword arguments. nargs is the number of positional arguments, kwnames are keys of keyword arguments. kwnames can be NULL.
* Issue #27810: Add _PyCFunction_FastCallKeywords()Victor Stinner2016-09-091-0/+26
| | | | | Use _PyCFunction_FastCallKeywords() in ceval.c: it allows to remove a lot of code from ceval.c which was only used to call C functions.
* Use Py_ssize_t type for number of argumentsVictor Stinner2016-08-241-2/+7
| | | | | Issue #27848: use Py_ssize_t rather than C int for the number of function positional and keyword arguments.
* _PyFunction_FastCallDict() supports keyword argsVictor Stinner2016-08-221-3/+3
| | | | | | | | Issue #27809: * Rename _PyFunction_FastCall() to _PyFunction_FastCallDict() * Rename _PyCFunction_FastCall() to _PyCFunction_FastCallDict() * _PyFunction_FastCallDict() now supports keyword arguments
* Add _PyObject_FastCall()Victor Stinner2016-08-191-0/+93
| | | | | | | | | | | | | | | | | Issue #27128: Add _PyObject_FastCall(), a new calling convention avoiding a temporary tuple to pass positional parameters in most cases, but create a temporary tuple if needed (ex: for the tp_call slot). The API is prepared to support keyword parameters, but the full implementation will come later (_PyFunction_FastCall() doesn't support keyword parameters yet). Add also: * _PyStack_AsTuple() helper function: convert a "stack" of parameters to a tuple. * _PyCFunction_FastCall(): fast call implementation for C functions * _PyFunction_FastCall(): fast call implementation for Python functions
* More typos in 3.5 documentation and commentsMartin Panter2015-10-071-1/+1
|
* Merge 3.4Andrew Svetlov2015-04-271-1/+1
|\
| * Issue #21354: PyCFunction_New function is exposed by python DLL again.Andrew Svetlov2015-04-271-1/+1
| |
* | Issue #23571: _Py_CheckFunctionResult() now gives the name of the functionVictor Stinner2015-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | which returned an invalid result (result+error or no result without error) in the exception message. Add also unit test to check that the exception contains the name of the function. Special case: the final _PyEval_EvalFrameEx() check doesn't mention the function since it didn't execute a single function but a whole frame.