Skip to content

Commit

Permalink
GH-99005: More intrinsics (GH-100774)
Browse files Browse the repository at this point in the history
* Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
  • Loading branch information
markshannon authored Jan 6, 2023
1 parent 659c260 commit 7806812
Show file tree
Hide file tree
Showing 16 changed files with 151 additions and 204 deletions.
22 changes: 3 additions & 19 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,6 @@ The Python compiler currently generates the following bytecode instructions.
Unary operations take the top of the stack, apply the operation, and push the
result back on the stack.

.. opcode:: UNARY_POSITIVE

Implements ``TOS = +TOS``.


.. opcode:: UNARY_NEGATIVE

Expand Down Expand Up @@ -906,13 +902,6 @@ iterations of the loop.
.. versionadded:: 3.6


.. opcode:: LIST_TO_TUPLE

Pops a list from the stack and pushes a tuple containing the same values.

.. versionadded:: 3.9


.. opcode:: LIST_EXTEND (i)

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


.. opcode:: ASYNC_GEN_WRAP

Wraps the value on top of the stack in an ``async_generator_wrapped_value``.
Used to yield in async generators.

.. versionadded:: 3.11


.. opcode:: HAVE_ARGUMENT

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

.. versionadded:: 3.12

Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_genobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

extern PyObject *_PyGen_yf(PyGenObject *);
extern PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
extern PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
extern PyObject *_PyAsyncGenValueWrapperNew(PyThreadState *state, PyObject *);

/* runtime lifecycle */

Expand Down
5 changes: 4 additions & 1 deletion Include/internal/pycore_intrinsics.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#define INTRINSIC_PRINT 1
#define INTRINSIC_IMPORT_STAR 2
#define INTRINSIC_STOPITERATION_ERROR 3
#define INTRINSIC_ASYNC_GEN_WRAP 4
#define INTRINSIC_UNARY_POSITIVE 5
#define INTRINSIC_LIST_TO_TUPLE 6

#define MAX_INTRINSIC_1 3
#define MAX_INTRINSIC_1 6

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

Expand Down
56 changes: 28 additions & 28 deletions Include/internal/pycore_opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 57 additions & 60 deletions Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7806812

Please sign in to comment.