diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2020-09-29 00:55:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-29 00:55:52 (GMT) |
commit | e8acc355d430b45f1c3ff83312e72272262a854f (patch) | |
tree | f0e7e832cbe141535675e5b05c581ceb1a4a0452 /Objects | |
parent | cb6db8b6ae47dccc1aa97830d0f05d29f31e0cbc (diff) | |
download | cpython-e8acc355d430b45f1c3ff83312e72272262a854f.zip cpython-e8acc355d430b45f1c3ff83312e72272262a854f.tar.gz cpython-e8acc355d430b45f1c3ff83312e72272262a854f.tar.bz2 |
bpo-41873: Add vectorcall for float() (GH-22432)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/floatobject.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 0606f29..d0af0ea 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1649,6 +1649,24 @@ float_subtype_new(PyTypeObject *type, PyObject *x) return newobj; } +static PyObject * +float_vectorcall(PyObject *type, PyObject * const*args, + size_t nargsf, PyObject *kwnames) +{ + if (!_PyArg_NoKwnames("float", kwnames)) { + return NULL; + } + + Py_ssize_t nargs = PyVectorcall_NARGS(nargsf); + if (!_PyArg_CheckPositional("float", nargs, 0, 1)) { + return NULL; + } + + PyObject *x = nargs >= 1 ? args[0] : _PyLong_Zero; + return float_new_impl((PyTypeObject *)type, x); +} + + /*[clinic input] float.__getnewargs__ [clinic start generated code]*/ @@ -1937,6 +1955,7 @@ PyTypeObject PyFloat_Type = { 0, /* tp_init */ 0, /* tp_alloc */ float_new, /* tp_new */ + .tp_vectorcall = (vectorcallfunc)float_vectorcall, }; int |