Commit Graph

623 Commits

Author SHA1 Message Date
Victor Stinner fda6d0acf0 next() uses FASTCALL 2017-01-17 04:09:14 +01:00
Victor Stinner 84b388bb80 getattr() uses METH_FASTCALL 2017-01-17 03:52:27 +01:00
Victor Stinner 773dc6dd06 __build_class__() builtin uses METH_FASTCALL 2017-01-16 23:46:26 +01:00
Victor Stinner bc08ab4598 Add _PY_FASTCALL_SMALL_STACK constant
Issue #28870: Add a new _PY_FASTCALL_SMALL_STACK constant, size of "small
stacks" allocated on the C stack to pass positional arguments to
_PyObject_FastCall().

_PyObject_Call_Prepend() now uses a small stack of 5 arguments (40 bytes)
instead of 8 (64 bytes), since it is modified to use _PY_FASTCALL_SMALL_STACK.
2016-12-15 12:40:53 +01:00
Victor Stinner f17c3de263 Use _PyObject_CallNoArg()
Replace:
    PyObject_CallFunctionObjArgs(callable, NULL)
with:
    _PyObject_CallNoArg(callable)
2016-12-06 18:46:19 +01:00
Nick Coghlan d77e5b7211 Merge #23722 from 3.6 2016-12-05 16:59:22 +10:00
Nick Coghlan 19d246745d Issue #23722: improve __classcell__ compatibility
Handling zero-argument super() in __init_subclass__ and
__set_name__ involved moving __class__ initialisation to
type.__new__. This requires cooperation from custom
metaclasses to ensure that the new __classcell__ entry
is passed along appropriately.

The initial implementation of that change resulted in abruptly
broken zero-argument super() support in metaclasses that didn't
adhere to the new requirements (such as Django's metaclass for
Model definitions).

The updated approach adopted here instead emits a deprecation
warning for those cases, and makes them work the same way they
did in Python 3.5.

This patch also improves the related class machinery documentation
to cover these details and to include more reader-friendly
cross-references and index entries.
2016-12-05 16:47:55 +10:00
Victor Stinner de4ae3d486 Backed out changeset b9c9691c72c5
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like
_PyObject_CallArg1() uses more stack memory than
PyObject_CallFunctionObjArgs().
2016-12-04 22:59:09 +01:00
Victor Stinner 27580c1fb5 Replace PyObject_CallFunctionObjArgs() with fastcall
* 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.
2016-12-01 14:43:22 +01:00
Serhiy Storchaka 85b0f5beb1 Added the const qualifier to char* variables that refer to readonly internal
UTF-8 represenatation of Unicode objects.
2016-11-20 10:16:47 +02:00
Serhiy Storchaka 06515833fe Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
2016-11-20 09:13:07 +02:00
Nick Coghlan 944368e1cc Issue #23722: Initialize __class__ from type.__new__()
The __class__ cell used by zero-argument super() is now initialized
from type.__new__ rather than __build_class__, so class methods
relying on that will now work correctly when called from metaclass
methods during class creation.

Patch by Martin Teichmann.
2016-09-11 14:45:49 +10:00
Eric Snow 4f29e75289 Issue #24254: Drop cls.__definition_order__. 2016-09-08 15:11:11 -07:00
Steve Dower cc16be85c0 Issue #27781: Change file system encoding on Windows to UTF-8 (PEP 529) 2016-09-08 10:35:16 -07:00
Victor Stinner 3466bde1cc Avoid calling functions with an empty string as format string
Directly pass NULL rather than an empty string.
2016-09-05 18:16:01 -07:00
Eric Snow 92a6c170e6 Issue #24254: Preserve class attribute definition order. 2016-09-05 14:50:11 -07:00
Raymond Hettinger 3b09cd64e0 Merge 2016-09-03 01:55:39 -07:00
Raymond Hettinger f0f1c239e4 Issue 27936: Fix inconsistent round() behavior between float and int 2016-09-03 01:55:11 -07:00
Raymond Hettinger f74c33ad5c Merge 2016-08-25 21:12:16 -07:00
Raymond Hettinger 7ea386e56e Issue 19504: Change "customise" to "customize" American spelling. 2016-08-25 21:11:50 -07:00
Victor Stinner 74319ae219 Use Py_ssize_t type for number of arguments
Issue #27848: use Py_ssize_t rather than C int for the number of function
positional and keyword arguments.
2016-08-25 00:04:09 +02:00
Victor Stinner cdb5cee980 Issue #27809: map_next() uses fast call
Use a small stack allocated in the C stack for up to 5 iterator functions,
otherwise allocates a stack on the heap memory.
2016-08-24 01:45:13 +02:00
Victor Stinner f0cba67d0b Backed out changeset 70f88b097f60 (map_next) 2016-08-24 00:54:47 +02:00
Victor Stinner a9ba1ab21b Issue #27809: map_next() uses fast call
Use a small stack allocated in the C stack for up to 5 iterator functions,
otherwise allocates a stack on the heap memory.
2016-08-23 17:56:06 +02:00
Victor Stinner d1c2a8e2b5 Issue #27809: builtin___build_class__() uses fast call 2016-08-23 01:34:35 +02:00
Victor Stinner 463b86a881 Issue #27809: Use _PyObject_FastCallDict()
Modify:

* init_subclass()
* builtin___build_class__()

Fix also a bug in init_subclass(): check for super() failure.
2016-08-22 23:33:13 +02:00
Victor Stinner 2990fa11bc Issue #27809: Use _PyObject_FastCallDict()
Modify:

* builtin_sorted()
* classmethoddescr_call()
* methoddescr_call()
* wrapperdescr_call()
2016-08-22 23:21:55 +02:00
Serhiy Storchaka 2954f83999 - Issue #27332: Fixed the type of the first argument of module-level functions
generated by Argument Clinic.  Patch by Petr Viktorin.
2016-07-07 18:20:03 +03:00
Serhiy Storchaka 1a2b24f02d Issue #27332: Fixed the type of the first argument of module-level functions
generated by Argument Clinic.  Patch by Petr Viktorin.
2016-07-07 17:35:15 +03:00
Serhiy Storchaka cfdfbb4d3c Issue #27342: Replaced some Py_XDECREFs with Py_DECREFs.
Patch by Xiang Zhang.
2016-06-18 09:44:03 +03:00
Serhiy Storchaka 24182a3aaa Restored parameter name "self" since gdb needs exact specific parameter names. 2016-05-05 16:21:35 +03:00
Serhiy Storchaka 7a9579c0ce Got rid of redundand "self" parameter declarations.
Argument Clinic is now able to infer all needed information.
2016-05-02 13:45:20 +03:00
Serhiy Storchaka 2e310b4c38 Regenerate Argument Clinic code for issue #26874. 2016-05-01 20:34:00 +03:00
Serhiy Storchaka df071730bb Regenerate Argument Clinic code for issue #26874. 2016-05-01 20:33:24 +03:00
Zachary Ware 5031a67821 Closes #26874: Merge with 3.5 2016-04-28 14:40:08 -05:00
Zachary Ware 7f227d9087 Issue #26874: Simplify the divmod docstring 2016-04-28 14:39:50 -05:00
Zachary Ware 54559b6511 Closes #26874: Merge with 3.5 2016-04-28 14:25:32 -05:00
Zachary Ware 4d4160af6a Issue #26874: Fix divmod docstring 2016-04-28 14:24:55 -05:00
Serhiy Storchaka 21a663ea28 Issue #26057: Got rid of nonneeded use of PyUnicode_FromObject(). 2016-04-13 15:37:23 +03:00
Martin Panter 9513ba3b8f Issue #24802: Merge null termination fixes from 3.5 2015-11-07 03:15:32 +00:00
Martin Panter 61d6e4ae9d Issue #24802: Merge null termination fixes from 3.4 into 3.5 2015-11-07 02:56:11 +00:00
Martin Panter eeb896c411 Issue #24802: Copy bytes-like objects to null-terminated buffers if necessary
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.
2015-11-07 02:32:21 +00:00
Martin Panter 5344da5c0d Issue #24402: Merge input() fix from 3.5 2015-10-10 02:09:41 +00:00
Martin Panter e02f8fc44d Issue #24402: Merge input() fix from 3.4 into 3.5 2015-10-10 01:55:23 +00:00
Martin Panter c9a6ab56cf Issue #24402: Fix input() when stdout.fileno() fails; diagnosed by Eryksun
Also factored out some test cases into a new PtyTests class.
2015-10-10 01:25:38 +00:00
Raymond Hettinger bd5f0e8c1c Hoist constant expression out of the inner loop. 2015-10-09 01:34:08 -04:00
Raymond Hettinger 5098b58381 Make comparison more consistent 2015-10-09 00:42:47 -04:00
Raymond Hettinger 501b4a7398 Use PyTuple_GET_SIZE like the adjacent code does. 2015-08-18 08:07:16 -07:00
Raymond Hettinger f109414094 Inline PyIter_Next() matching the other itertools code. 2015-08-18 00:20:20 -07:00
Serhiy Storchaka 8b2e8b6cce Specify default values of semantic booleans in Argument Clinic generated signatures as booleans. 2015-05-30 11:30:39 +03:00