Commit Graph

6545 Commits

Author SHA1 Message Date
Inada Naoki fb26504d14
bpo-37543: optimize pymalloc (#14674)
PyObject_Malloc() and PyObject_Free() inlines pymalloc_alloc and
pymalloc_free partially.
But when PGO is not used, compiler don't know where is the hot part
in pymalloc_alloc and pymalloc_free.
2019-07-17 21:23:57 +09:00
Jeroen Demeyer 1dbd084f1f bpo-29548: no longer use PyEval_Call* functions (GH-14683) 2019-07-12 00:57:32 +09:00
Jeroen Demeyer 59ad110d7a bpo-37547: add _PyObject_CallMethodOneArg (GH-14685) 2019-07-11 17:59:05 +09:00
Tim Peters b64c2c66e5
Fix compiler warning in new code. (#14690)
uintptr_t is an integer type, and can't be compared to NULL directly.
2019-07-10 16:24:01 -05:00
Neil Schemenauer 5d25f2b703
bpo-37537: Compute allocated blocks in _Py_GetAllocatedBlocks() (#14680)
Keeping an account of allocated blocks slows down _PyObject_Malloc()
and _PyObject_Free() by a measureable amount.  Have
_Py_GetAllocatedBlocks() iterate over the arenas to sum up the
allocated blocks for pymalloc.
2019-07-10 12:04:16 -07:00
Jeroen Demeyer 762f93ff2e bpo-37337: Add _PyObject_CallMethodNoArgs() (GH-14267) 2019-07-08 17:19:25 +09:00
Jeroen Demeyer 7b57c03a7c bpo-37151: remove _PyMethodDef_RawFastCall* functions (GH-14603) 2019-07-05 17:43:22 +02:00
Jeroen Demeyer 0d722f3cd6 bpo-36974: separate vectorcall functions for each calling convention (GH-13781) 2019-07-05 14:48:24 +02:00
Jeroen Demeyer 196a530e00 bpo-37483: add _PyObject_CallOneArg() function (#14558) 2019-07-04 19:31:34 +09:00
Jeroen Demeyer 53c2143440 bpo-37233: optimize method_vectorcall in case of totalargs == 0 (GH-14550) 2019-07-03 19:53:59 +09:00
Jeroen Demeyer d4efd917ac bpo-36904: Optimize _PyStack_UnpackDict (GH-14517) 2019-07-02 18:49:40 +09:00
Pablo Galindo 4a2edc34a4 bpo-37221: Add PyCode_NewWithPosOnlyArgs to be used internally and set PyCode_New as a compatibility wrapper (GH-13959)
Add PyCode_NewEx to be used internally and set PyCode_New as a compatibility wrapper
2019-07-01 12:35:05 +02:00
Jeroen Demeyer b1263d5a60 bpo-37337: Add _PyObject_VectorcallMethod() (GH-14228) 2019-06-28 18:49:00 +09:00
Brandt Bucher 2a7d596f27 bpo-37417: Fix error handling in bytearray.extend. (GH-14407) 2019-06-26 22:06:18 +03:00
Victor Stinner ed076ed467
bpo-37388: Add PyUnicode_Decode(str, 0) fast-path (GH-14385)
Add a fast-path to PyUnicode_Decode() for size equals to 0.
2019-06-26 01:49:32 +02:00
Victor Stinner 22eb689cf3
bpo-37388: Development mode check encoding and errors (GH-14341)
In development mode and in debug build, encoding and errors arguments
are now checked on string encoding and decoding operations. Examples:
open(), str.encode() and bytes.decode().

By default, for best performances, the errors argument is only
checked at the first encoding/decoding error, and the encoding
argument is sometimes ignored for empty strings.
2019-06-26 00:51:05 +02:00
Serhiy Storchaka 894263ba80
bpo-24214: Fixed the UTF-8 and UTF-16 incremental decoders. (GH-14304)
* The UTF-8 incremental decoders fails now fast if encounter
  a sequence that can't be handled by the error handler.
* The UTF-16 incremental decoders with the surrogatepass error
  handler decodes now a lone low surrogate with final=False.
2019-06-25 11:54:18 +03:00
Jeroen Demeyer a8b27e623d bpo-36974: inherit tp_vectorcall_offset unconditionally (GH-13858) 2019-06-24 12:41:05 +02:00
Inada Naoki 770847a7db
bpo-37348: optimize decoding ASCII string (GH-14283)
`_PyUnicode_Writer` is a relatively complex structure.  Initializing it is significant overhead when decoding short ASCII string.
2019-06-24 12:30:24 +09:00
Jeroen Demeyer 7e1a9aacff bpo-37151: remove _PyCFunction_FastCallDict (GH-14269) 2019-06-21 00:38:45 +09:00
Victor Stinner b45d259bdd
bpo-36710: Use tstate in pylifecycle.c (GH-14249)
In pylifecycle.c: pass tstate argument, rather than interp argument,
to functions.
2019-06-20 00:05:23 +02:00
Jeroen Demeyer 59543347d1 bpo-37151: remove _PyFunction_FastCallDict (GH-13864) 2019-06-18 20:05:41 +09:00
Jeroen Demeyer 988e6aa322 bpo-37233: use _PY_FASTCALL_SMALL_STACK in method_vectorcall (GH-13974) 2019-06-18 17:56:53 +09:00
Jeroen Demeyer c78fe320db bpo-37151: use PyVectorcall_Call for all calls of "method" (GH-13972) 2019-06-18 17:50:28 +09:00
Victor Stinner 2ff58a24e8
bpo-37194: Add a new public PyObject_CallNoArgs() function (GH-13890)
Add a new public PyObject_CallNoArgs() function to the C API: call a
callable Python object without any arguments.

It is the most efficient way to call a callback without any argument.
On x86-64, for example, PyObject_CallFunctionObjArgs(func, NULL)
allocates 960 bytes on the stack per call, whereas
PyObject_CallNoArgs(func) only allocates 624 bytes per call.

It is excluded from stable ABI 3.8.

Replace private _PyObject_CallNoArg() with public
PyObject_CallNoArgs() in C extensions: _asyncio, _datetime,
_elementtree, _pickle, _tkinter and readline.
2019-06-17 14:27:23 +02:00
Jeroen Demeyer 2e9954d347 bpo-36922: use Py_TPFLAGS_METHOD_DESCRIPTOR in lookup_maybe_method() (GH-13865) 2019-06-17 20:53:20 +09:00
Jeroen Demeyer 0456df4a55 bpo-37231: remove _PyObject_FastCall_Prepend (GH-14153) 2019-06-17 20:41:32 +09:00
Hai Shi c83356cae2 closes bpo-37300: Remove unnecessary Py_XINCREF in classobject.c. (GH-14120) 2019-06-16 13:19:19 -07:00
Jeroen Demeyer b2f94730d9 bpo-37249: add declaration of _PyObject_GetMethod (GH-14015) 2019-06-14 19:37:15 +09:00
Jeroen Demeyer b4b814b398 bpo-37231: optimize calls of special methods (GH-13973) 2019-06-13 18:26:44 +09:00
Tim Peters d1c85a27ea
bpo-37257: obmalloc: stop simple arena thrashing (#14039)
GH-14039:  allow (no more than) one wholly empty arena on the usable_arenas list.

This prevents thrashing in some easily-provoked simple cases that could end up creating and destroying an arena on each loop iteration in client code.   Intuitively, if the only arena on the list becomes empty, it makes scant sense to give it back to the system unless we know we'll never need another free pool again before another arena frees a pool.  If the latter obtains, then - yes - this will "waste" an arena.
2019-06-12 22:41:03 -05:00
Paul Monson ff6bb0aa95 bpo-37236: pragma optimize off for _Py_c_quot on Windows arm64 (GH-13983) 2019-06-12 11:08:40 -07:00
Victor Stinner 376ce9852e
bpo-26219: Fix compiler warning in _PyCode_InitOpcache() (GH-13997)
Fix MSVC warning:

    objects\codeobject.c(285): warning C4244: '=':
    conversion from 'Py_ssize_t' to 'unsigned char',
    possible loss of data
2019-06-12 04:41:16 +02:00
Raymond Hettinger 1f11cf9521
bpo-37219: Remove erroneous optimization for differencing an empty set (GH-13965) 2019-06-11 01:15:24 -07:00
Jeroen Demeyer 1f9531764c bpo-37138: fix undefined behaviour with memcpy() on NULL array (GH-13867) 2019-06-07 11:01:53 -07:00
Jeroen Demeyer 3f345c3925 bpo-37151: simplify classmethoddescr_call (GH-13340) 2019-06-07 12:20:23 +02:00
Zackery Spytz dc2476500d bpo-37170: Fix the cast on error in PyLong_AsUnsignedLongLongMask() (GH-13860) 2019-06-06 22:39:23 +02:00
Victor Stinner ea9f168957
bpo-26219: Fix compiler warning in _PyCode_InitOpcache() (GH-13809)
Fix this MSVC warning:

    objects\codeobject.c(264): warning C4244: '=':
    conversion from 'Py_ssize_t' to 'unsigned char', possible loss of data
2019-06-04 17:08:24 +02:00
Inada Naoki 91234a1636
bpo-26219: per opcode cache for LOAD_GLOBAL (GH-12884)
This patch implements per opcode cache mechanism, and use it in
only LOAD_GLOBAL opcode.

Based on Yury's opcache3.patch in bpo-26219.
2019-06-03 21:30:58 +09:00
Petr Viktorin 1e375c6269
bpo-36027: Really fix "incompatible pointer type" compiler warning (GH-13761)
Apologies for the earlier hasty attempt.
2019-06-03 02:28:29 +02:00
Jeroen Demeyer be718c33f0 bpo-36974: add some assertions for PEP 590 (GH-13682) 2019-06-03 01:57:22 +02:00
Petr Viktorin 7f4ae1b2cc
bpo-37012: Clean up special cases in PyType_FromSpecWithBases slot assignments (GH-13496)
The main slot assignment loop is now if-else if ladder, making the
control flow clearer.

Based on suggestion by Victor Stinner in:
https://github.com/python/cpython/pull/10304/#issuecomment-491123026
2019-06-03 01:31:12 +02:00
Petr Viktorin e584cbff1e
bpo-36027 bpo-36974: Fix "incompatible pointer type" compiler warnings (GH-13758) 2019-06-03 01:08:14 +02:00
Petr Viktorin fb9423fd0a
bpo-36974: Make tp_call=PyVectorcall_Call work for inherited types (GH-13699)
When inheriting a heap subclass from a vectorcall class that sets
`.tp_call=PyVectorcall_Call` (as recommended in PEP 590), the subclass does
not inherit `_Py_TPFLAGS_HAVE_VECTORCALL`, and thus `PyVectorcall_Call` does
not work for it.

This attempts to solve the issue by:
* always inheriting `tp_vectorcall_offset` unless `tp_call` is overridden
  in the subclass
* inheriting _Py_TPFLAGS_HAVE_VECTORCALL for static types, unless `tp_call`
  is overridden
* making `PyVectorcall_Call` ignore `_Py_TPFLAGS_HAVE_VECTORCALL`

This means it'll be ever more important to only call `PyVectorcall_Call`
on classes that support vectorcall. In `PyVectorcall_Call`'s intended role
as `tp_call` filler, that's not a problem.
2019-06-02 23:52:20 +02:00
Pablo Galindo 3caf4de6f0
Call PyObject_GC_UnTrack in structseq dealloc (GH-13751) 2019-06-02 21:52:49 +01:00
Pablo Galindo 7ffcf848df
bpo-37126: Allow structseq objects to be tracked by the GC (GH-13729) 2019-06-02 15:45:13 +01:00
Mark Dickinson c52996785a
bpo-36027: Extend three-argument pow to negative second argument (GH-13266) 2019-06-02 10:24:06 +01:00
Serhiy Storchaka bdbad71b9d
bpo-20092. Use __index__ in constructors of int, float and complex. (GH-13108) 2019-06-02 00:05:48 +03:00
Pablo Galindo 3b57f50efc
bpo-36842: Pass positional only parameters to code_new audit hook (GH-13707) 2019-06-01 21:18:48 +01:00
Francisco Couzo 9843bc110d Improve exception message for str.format (GH-12675) 2019-06-01 10:14:00 -07:00