cpython: 28e280915508 (original) (raw)

--- a/Doc/library/dis.rst +++ b/Doc/library/dis.rst @@ -777,6 +777,14 @@ All of the following opcodes use their a .. versionadded:: 3.6 +.. opcode:: BUILD_STRING (count) +

+ .. opcode:: LOAD_ATTR (namei) Replaces TOS with getattr(TOS, co_names[namei]).

--- a/Include/opcode.h +++ b/Include/opcode.h @@ -123,6 +123,7 @@ extern "C" { #define SETUP_ASYNC_WITH 154 #define FORMAT_VALUE 155 #define BUILD_CONST_KEY_MAP 156 +#define BUILD_STRING 157 /* EXCEPT_HANDLER is a special, implicit block type which is created when entering an except handler. It is not an opcode but we define it here

--- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -1955,6 +1955,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_Join( PyObject seq / Sequence object */ ); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(

+#endif /* Py_LIMITED_API / + / Return 1 if substr matches str[start:end] at the given tail end, 0 otherwise. */

--- a/Lib/importlib/_bootstrap_external.py +++ b/Lib/importlib/_bootstrap_external.py @@ -232,7 +232,8 @@ def _write_atomic(path, data, mode=0o666

Python 3.6a1 3370 (16 bit wordcode)

Python 3.6a1 3371 (add BUILD_CONST_KEY_MAP opcode #27140)

Python 3.6a1 3372 (MAKE_FUNCTION simplification, remove MAKE_CLOSURE

+# #27095) +# Python 3.6b1 3373 (add BUILD_STRING opcode #27078) #

MAGIC must change whenever the bytecode emitted by the compiler may no

longer be understood by older implementations of the eval loop (usually

@@ -241,7 +242,7 @@ def _write_atomic(path, data, mode=0o666

Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array

in PC/launcher.c must also be updated.

-MAGIC_NUMBER = (3372).to_bytes(2, 'little') + b'\r\n' +MAGIC_NUMBER = (3373).to_bytes(2, 'little') + b'\r\n' _RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c _PYCACHE = 'pycache'

--- a/Lib/opcode.py +++ b/Lib/opcode.py @@ -213,5 +213,6 @@ def_op('BUILD_SET_UNPACK', 153) def_op('FORMAT_VALUE', 155) def_op('BUILD_CONST_KEY_MAP', 156) +def_op('BUILD_STRING', 157) del def_op, name_op, jrel_op, jabs_op

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ What's New in Python 3.6.0 beta 1 Core and Builtins ----------------- +- Issue #27078: Added BUILD_STRING opcode. Optimized f-strings evaluation. +

--- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -675,13 +675,31 @@ PyObject_Format(PyObject *obj, PyObject PyObject *result = NULL; _Py_IDENTIFIER(format);

+

+ /* If no format_spec is provided, use an empty string */ if (format_spec == NULL) { empty = PyUnicode_New(0, 0); format_spec = empty; }

--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -9892,20 +9892,10 @@ case_operation(PyObject *self, PyObject * PyUnicode_Join(PyObject *separator, PyObject *seq) {

fseq = PySequence_Fast(seq, "can only join an iterable"); if (fseq == NULL) { @@ -9916,21 +9906,39 @@ PyUnicode_Join(PyObject *separator, PyOb * so we are sure that fseq won't be mutated. */

+} + +PyObject * +_PyUnicode_JoinArray(PyObject *separator, PyObject **items, Py_ssize_t seqlen) +{

+ /* If empty sequence, return u"". */ if (seqlen == 0) {

@@ -10065,13 +10073,11 @@ PyUnicode_Join(PyObject *separator, PyOb assert(res_offset == PyUnicode_GET_LENGTH(res)); }

--- a/PC/launcher.c +++ b/PC/launcher.c @@ -1089,7 +1089,7 @@ static PYC_MAGIC magic_values[] = { { 3190, 3230, L"3.3" }, { 3250, 3310, L"3.4" }, { 3320, 3351, L"3.5" },

--- a/Python/ceval.c +++ b/Python/ceval.c @@ -2538,6 +2538,24 @@ PyObject * DISPATCH(); }

+ TARGET(BUILD_TUPLE) { PyObject *tup = PyTuple_New(oparg); if (tup == NULL)

--- a/Python/compile.c +++ b/Python/compile.c @@ -970,6 +970,7 @@ PyCompile_OpcodeStackEffect(int opcode, case BUILD_TUPLE: case BUILD_LIST: case BUILD_SET:

@@ -3315,31 +3316,8 @@ compiler_call(struct compiler *c, expr_t static int compiler_joined_str(struct compiler *c, expr_ty e) {

-

-

-

-

--- a/Python/importlib.h +++ b/Python/importlib.h @@ -1676,210 +1676,209 @@ const unsigned char _Py_M__importlib[] = 115,116,238,3,0,0,115,34,0,0,0,0,10,10,1,8, 1,8,1,10,1,10,1,12,1,10,1,10,1,14,1,2, 1,14,1,16,4,14,1,10,1,2,1,24,1,114,195,0,

};

--- a/Python/importlib_external.h +++ b/Python/importlib_external.h @@ -242,7 +242,7 @@ const unsigned char _Py_M__importlib_ext 101,95,97,116,111,109,105,99,106,0,0,0,115,26,0,0, 0,0,5,16,1,6,1,26,1,2,3,14,1,20,1,16, 1,14,1,2,1,14,1,14,1,6,1,114,58,0,0,0,

--- a/Python/opcode_targets.h +++ b/Python/opcode_targets.h @@ -156,7 +156,7 @@ static void *opcode_targets[256] = { &&TARGET_SETUP_ASYNC_WITH, &&TARGET_FORMAT_VALUE, &&TARGET_BUILD_CONST_KEY_MAP,