diff options
author | Mark Shannon <mark@hotpy.org> | 2023-01-06 14:47:57 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-06 14:47:57 (GMT) |
commit | 78068126a1f2172ff61a0871ba43d8530bc73905 (patch) | |
tree | aa42d4c6d64130587e2f62d61389496693de86e4 /Python/intrinsics.c | |
parent | 659c2607f5b44a8a18a0840d1ac39df8a3219dd5 (diff) | |
download | cpython-78068126a1f2172ff61a0871ba43d8530bc73905.zip cpython-78068126a1f2172ff61a0871ba43d8530bc73905.tar.gz cpython-78068126a1f2172ff61a0871ba43d8530bc73905.tar.bz2 |
GH-99005: More intrinsics (GH-100774)
* Remove UNARY_POSITIVE, LIST_TO_TUPLE and ASYNC_GEN_WRAP, replacing them with intrinsics.
Diffstat (limited to 'Python/intrinsics.c')
-rw-r--r-- | Python/intrinsics.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Python/intrinsics.c b/Python/intrinsics.c index 07b9c6a..ae17758 100644 --- a/Python/intrinsics.c +++ b/Python/intrinsics.c @@ -185,10 +185,26 @@ stopiteration_error(PyThreadState* tstate, PyObject *exc) return Py_NewRef(exc); } +static PyObject * +unary_pos(PyThreadState* unused, PyObject *value) +{ + return PyNumber_Positive(value); +} + +static PyObject * +list_to_tuple(PyThreadState* unused, PyObject *v) +{ + assert(PyList_Check(v)); + return _PyTuple_FromArray(((PyListObject *)v)->ob_item, Py_SIZE(v)); +} + instrinsic_func1 _PyIntrinsics_UnaryFunctions[] = { [0] = no_intrinsic, [INTRINSIC_PRINT] = print_expr, [INTRINSIC_IMPORT_STAR] = import_star, [INTRINSIC_STOPITERATION_ERROR] = stopiteration_error, + [INTRINSIC_ASYNC_GEN_WRAP] = _PyAsyncGenValueWrapperNew, + [INTRINSIC_UNARY_POSITIVE] = unary_pos, + [INTRINSIC_LIST_TO_TUPLE] = list_to_tuple, }; |