Skip to content

Commit 7806812

Browse files
authored
GH-99005: More intrinsics (GH-100774)
* Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
1 parent 659c260 commit 7806812

16 files changed

+151
-204
lines changed

Doc/library/dis.rst

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,6 @@ The Python compiler currently generates the following bytecode instructions.
460460
Unary operations take the top of the stack, apply the operation, and push the
461461
result back on the stack.
462462

463-
.. opcode:: UNARY_POSITIVE
464-
465-
Implements ``TOS = +TOS``.
466-
467463

468464
.. opcode:: UNARY_NEGATIVE
469465

@@ -906,13 +902,6 @@ iterations of the loop.
906902
.. versionadded:: 3.6
907903

908904

909-
.. opcode:: LIST_TO_TUPLE
910-
911-
Pops a list from the stack and pushes a tuple containing the same values.
912-
913-
.. versionadded:: 3.9
914-
915-
916905
.. opcode:: LIST_EXTEND (i)
917906

918907
Calls ``list.extend(TOS1[-i], TOS)``. Used to build lists.
@@ -1372,14 +1361,6 @@ iterations of the loop.
13721361
.. versionadded:: 3.11
13731362

13741363

1375-
.. opcode:: ASYNC_GEN_WRAP
1376-
1377-
Wraps the value on top of the stack in an ``async_generator_wrapped_value``.
1378-
Used to yield in async generators.
1379-
1380-
.. versionadded:: 3.11
1381-
1382-
13831364
.. opcode:: HAVE_ARGUMENT
13841365

13851366
This is not really an opcode. It identifies the dividing line between
@@ -1411,6 +1392,9 @@ iterations of the loop.
14111392
* ``1`` Prints the argument to standard out. Used in the REPL.
14121393
* ``2`` Performs ``import *`` for the named module.
14131394
* ``3`` Extracts the return value from a ``StopIteration`` exception.
1395+
* ``4`` Wraps an aync generator value
1396+
* ``5`` Performs the unary ``+`` operation
1397+
* ``6`` Converts a list to a tuple
14141398

14151399
.. versionadded:: 3.12
14161400

Include/internal/pycore_genobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern "C" {
1010

1111
extern PyObject *_PyGen_yf(PyGenObject *);
1212
extern PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
13-
extern PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
13+
extern PyObject *_PyAsyncGenValueWrapperNew(PyThreadState *state, PyObject *);
1414

1515
/* runtime lifecycle */
1616

Include/internal/pycore_intrinsics.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
#define INTRINSIC_PRINT 1
33
#define INTRINSIC_IMPORT_STAR 2
44
#define INTRINSIC_STOPITERATION_ERROR 3
5+
#define INTRINSIC_ASYNC_GEN_WRAP 4
6+
#define INTRINSIC_UNARY_POSITIVE 5
7+
#define INTRINSIC_LIST_TO_TUPLE 6
58

6-
#define MAX_INTRINSIC_1 3
9+
#define MAX_INTRINSIC_1 6
710

811
typedef PyObject *(*instrinsic_func1)(PyThreadState* tstate, PyObject *value);
912

Include/internal/pycore_opcode.h

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/opcode.h

Lines changed: 57 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)