summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
Commit message (Collapse)AuthorAgeFilesLines
...
* | Uniformize argument names of "call" functionsVictor Stinner2016-12-061-70/+78
| | | | | | | | | | | | | | | | | | | | | | | | Issue #28838: Rename parameters of the "calls" functions of the Python C API. * Rename 'callable_object' and 'func' to 'callable': any Python callable object is accepted, not only Python functions * Rename 'method' and 'nameid' to 'name' (method name) * Rename 'o' to 'obj' * Move, fix and update documentation of PyObject_CallXXX() functions in abstract.h * Update also the documentaton of the C API (update parameter names)
* | Issue #28858: Remove _PyObject_CallArg1() macroVictor Stinner2016-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | Replace _PyObject_CallArg1(func, arg) with PyObject_CallFunctionObjArgs(func, arg, NULL) Using the _PyObject_CallArg1() macro increases the usage of the C stack, which was unexpected and unwanted. PyObject_CallFunctionObjArgs() doesn't have this issue.
* | Backed out changeset b9c9691c72c5Victor Stinner2016-12-041-4/+4
| | | | | | | | | | | | Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
* | Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner2016-12-011-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
* | Backed out changeset 7efddbf1aa70Victor Stinner2016-11-301-62/+60
| |
* | Uniformize argument names of "call" functionsVictor Stinner2016-11-291-60/+62
| | | | | | | | | | | | | | | | | | | | | | | | * Callable object: callable, o, callable_object => func * Object for method calls: o => obj * Method name: name or nameid => method Cleanup also the C code: * Don't initialize variables to NULL if they are not used before their first assignement * Add braces for readability
* | Issue #19569: Compiler warnings are now emitted if use most of deprecatedSerhiy Storchaka2016-11-201-11/+17
|/ | | | functions.
* Issue #28410: Added _PyErr_FormatFromCause() -- the helper for raisingSerhiy Storchaka2016-10-211-12/+10
| | | | | | | | new exception with setting current exception as __cause__. _PyErr_FormatFromCause(exception, format, args...) is equivalent to Python raise exception(format % args) from sys.exc_info()[1]
* remove unneeded castBenjamin Peterson2016-09-231-1/+1
|
* va_end() all va_copy()ed va_lists.Christian Heimes2016-09-211-0/+2
|
* replace usage of Py_VA_COPY with the (C99) standard va_copyBenjamin Peterson2016-09-211-1/+1
|
* Issue #28126: Replace Py_MEMCPY with memcpy(). Visual Studio can properly ↵Christian Heimes2016-09-131-2/+2
| | | | optimize memcpy().
* Document kwnames in _PyObject_FastCallKeywords() and _PyStack_AsDict()Victor Stinner2016-09-121-0/+3
| | | | Issue #27213.
* Revert change f860b7a775c5Victor Stinner2016-09-121-19/+7
| | | | | Revert change "Issue #27213: Reintroduce checks in _PyStack_AsDict()", pushed by mistake.
* ssue #27213: Reintroduce checks in _PyStack_AsDict()Victor Stinner2016-09-121-7/+19
|
* Issue #27213: Fixed different issues with reworked CALL_FUNCTION* opcodes.Serhiy Storchaka2016-09-111-19/+7
| | | | | | | | | | | * 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/+56
| | | | | | | | | | | 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-2/+5
| | | | | 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.
* Add _PyObject_FastCallKeywords()Victor Stinner2016-09-091-0/+68
| | | | | | | | | | Issue #27830: Add _PyObject_FastCallKeywords(): avoid the creation of a temporary dictionary for keyword arguments. Other changes: * Cleanup call_function() and fast_function() (ex: rename nk to nkwargs) * Remove now useless do_call(), replaced with _PyObject_FastCallKeywords()
* Issue #27078: Added BUILD_STRING opcode. Optimized f-strings evaluation.Serhiy Storchaka2016-09-061-1/+19
|
* Issue #27830: Remove unused _PyStack_AsDict()Victor Stinner2016-09-051-34/+0
| | | | I forgot to remove this function, I made a mistake in my revert.
* Issue #27830: Revert, remove _PyFunction_FastCallKeywords()Victor Stinner2016-08-251-45/+0
|
* method_call() and slot_tp_new() now uses fast callVictor Stinner2016-08-241-0/+39
| | | | | | | Issue #27841: Add _PyObject_Call_Prepend() helper function to prepend an argument to existing arguments to call a function. This helper uses fast calls. Modify method_call() and slot_tp_new() to use _PyObject_Call_Prepend().
* Issue #27830: Fix _PyObject_FastCallKeywords()Victor Stinner2016-08-241-1/+1
| | | | Pass stack, not unrelated and uninitialized args!
* _PyObject_FastCallDict(): avoid _Py_CheckFunctionResult()Victor Stinner2016-08-241-2/+2
| | | | | _PyObject_FastCallDict() only requires _Py_CheckFunctionResult() for the slow-path. Other cases already check for the result.
* Add _PyObject_FastCallKeywords()Victor Stinner2016-08-241-0/+79
| | | | | | Issue #27830: Similar to _PyObject_FastCallDict(), but keyword arguments are also passed in the same C array than positional arguments, rather than being passed as a Python dict.
* Use Py_ssize_t type for number of argumentsVictor Stinner2016-08-241-1/+1
| | | | | Issue #27848: use Py_ssize_t rather than C int for the number of function positional and keyword arguments.
* PyObject_CallMethodObjArgs() now uses fast callVictor Stinner2016-08-231-32/+71
| | | | | | | | | | | | | | | | | | | Issue #27809: * PyObject_CallMethodObjArgs(), _PyObject_CallMethodIdObjArgs() and PyObject_CallFunctionObjArgs() now use fast call to avoid the creation of a temporary tuple * Rename objargs_mktuple() to objargs_mkstack() * objargs_mkstack() now stores objects in a C array using borrowed references, instead of storing arguments into a tuple objargs_mkstack() uses a small buffer allocated on the C stack for 5 arguments or less, or allocates a buffer in the heap memory. Note: this change is different than the change 0e4f26083bbb, I fixed the test to decide if the small stack can be used or not. sizeof(PyObject**) was also replaced with sizeof(stack[0]) since the sizeof() was wrong (but gave the same result).
* Backed out changeset 0e4f26083bbb (PyObject_CallMethodObjArgs)Victor Stinner2016-08-231-71/+32
|
* PyObject_CallMethodObjArgs() now uses fast callVictor Stinner2016-08-231-32/+71
| | | | | | | | | | | | | | Issue #27809: * PyObject_CallMethodObjArgs(), _PyObject_CallMethodIdObjArgs() and PyObject_CallFunctionObjArgs() now use fast call to avoid the creation of a temporary tuple * Rename objargs_mktuple() to objargs_mkstack() * objargs_mkstack() now stores objects in a C array using borrowed references, instead of storing arguments into a tuple objargs_mkstack() uses a small buffer allocated on the C stack for 5 arguments or less, or allocates a buffer in the heap memory.
* _PyFunction_FastCallDict() supports keyword argsVictor Stinner2016-08-221-6/+5
| | | | | | | | Issue #27809: * Rename _PyFunction_FastCall() to _PyFunction_FastCallDict() * Rename _PyCFunction_FastCall() to _PyCFunction_FastCallDict() * _PyFunction_FastCallDict() now supports keyword arguments
* Rename _PyObject_FastCall() to _PyObject_FastCallDict()Victor Stinner2016-08-221-6/+6
| | | | | | | | Issue #27809: * Rename _PyObject_FastCall() function to _PyObject_FastCallDict() * Add _PyObject_FastCall(), _PyObject_CallNoArg() and _PyObject_CallArg1() macros calling _PyObject_FastCallDict()
* Issue #26984: int() now always returns an instance of exact int.Serhiy Storchaka2016-08-211-12/+23
|
* Fix PyObject_Call() parameter namesVictor Stinner2016-08-191-2/+4
| | | | | | Issue #27128: arg=>args, kw=>kwargs. Same change for PyEval_CallObjectWithKeywords().
* Avoid call_function_tail() for empty format strVictor Stinner2016-08-191-20/+19
| | | | | | Issue #27128, PyObject_CallFunction(), _PyObject_FastCall() and callmethod(): if the format string of parameters is empty, avoid the creation of an empty tuple: call _PyObject_FastCall() without parameters.
* PEP 7: add {...} around null_error() in abstract.cVictor Stinner2016-08-191-28/+65
| | | | Issue #27128.
* Cleanup callmethod()Victor Stinner2016-08-191-2/+6
| | | | | | | Make callmethod() less weird: don't decrement func reference counter, the caller is now responsible to do that. Issue #27128.
* Cleanup call_function_tail()Victor Stinner2016-08-191-20/+29
| | | | | | | | Make call_function_tail() less weird: don't decrement args reference counter, the caller is now responsible to do that. The caller now also checks if args is NULL. Issue #27128.
* call_function_tail() uses fast callVictor Stinner2016-08-191-13/+6
| | | | | | | | | | | Issue #27128: Modify call_function_tail() to use _PyObject_FastCall() when args is not a tuple to avoid the creation of a temporary tuple. call_function_tail() is used by: * PyObject_CallFunction() * PyObject_CallMethod() * _PyObject_CallMethodId()
* Add _PyObject_FastCall()Victor Stinner2016-08-191-0/+76
| | | | | | | | | | | | | | | | | 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
* Issue #27581: Merge overflow fix from 3.5Martin Panter2016-07-251-4/+5
|\
| * Issue #27581: Don’t rely on overflow wrapping in PySequence_Tuple()Martin Panter2016-07-251-4/+5
| | | | | | | | Patch by Xiang Zhang.
* | Merge spelling fixes from 3.5Martin Panter2016-06-201-1/+1
|\ \ | |/
| * Fix spelling errors in code commentsMartin Panter2016-06-201-2/+2
| |
* | Comment fixes extracted from patch by Demur Rumed.Serhiy Storchaka2016-06-121-1/+1
| |
* | Issue #26983: float() now always return an instance of exact float.Serhiy Storchaka2016-06-031-6/+24
| | | | | | | | | | | | The deprecation warning is emitted if __float__ returns an instance of a strict subclass of float. In a future versions of Python this can be an error.
* | Issue #24802: Merge null termination fixes from 3.5Martin Panter2015-11-071-2/+20
|\ \ | |/
| * Issue #24802: Merge null termination fixes from 3.4 into 3.5Martin Panter2015-11-071-2/+20
| |\
| | * Issue #24802: Copy bytes-like objects to null-terminated buffers if necessaryMartin Panter2015-11-071-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | This avoids possible buffer overreads when int(), float(), compile(), exec() and eval() are passed bytes-like objects. Similar code is removed from the complex() constructor, where it was not reachable. Patch by John Leitch, Serhiy Storchaka and Martin Panter.
* | | Issue #25556: Add assertions to PyObject_GetItem() to ensure that an exceptionVictor Stinner2015-11-051-3/+8
|/ / | | | | | | | | | | | | is raised when it returns NULL. Simplify also ceval.c: rely on the fact that PyObject_GetItem() raised an exception when it returns NULL.