summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-09-06 19:07:53 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-09-06 19:07:53 (GMT)
commitea525a2d1a798f529b015f86b174d478806ac7ec (patch)
tree4ed79494c2a6a8e3460027a246020d25c1eaca16 /Python/ceval.c
parent620bb277f89ba373b8c50e1a9fb9c8ba77a245c4 (diff)
downloadcpython-ea525a2d1a798f529b015f86b174d478806ac7ec.zip
cpython-ea525a2d1a798f529b015f86b174d478806ac7ec.tar.gz
cpython-ea525a2d1a798f529b015f86b174d478806ac7ec.tar.bz2
Issue #27078: Added BUILD_STRING opcode. Optimized f-strings evaluation.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 05563a0..bf19a5b 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -2538,6 +2538,24 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
DISPATCH();
}
+ TARGET(BUILD_STRING) {
+ PyObject *str;
+ PyObject *empty = PyUnicode_New(0, 0);
+ if (empty == NULL) {
+ goto error;
+ }
+ str = _PyUnicode_JoinArray(empty, stack_pointer - oparg, oparg);
+ Py_DECREF(empty);
+ if (str == NULL)
+ goto error;
+ while (--oparg >= 0) {
+ PyObject *item = POP();
+ Py_DECREF(item);
+ }
+ PUSH(str);
+ DISPATCH();
+ }
+
TARGET(BUILD_TUPLE) {
PyObject *tup = PyTuple_New(oparg);
if (tup == NULL)