[Python-checkins] Revert "bpo-46131: add fastpath for PyFloat_Check() (GH-30200)" (GH-30208)
rhettinger
webhook-mailer at python.org
Sun Dec 19 16:05:55 EST 2021
https://github.com/python/cpython/commit/29ea68bd1dcf30842c2ed908a6d815bc1d90f484
commit: 29ea68bd1dcf30842c2ed908a6d815bc1d90f484
branch: main
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2021-12-19T15:05:46-06:00
summary:
Revert "bpo-46131: add fastpath for PyFloat_Check() (GH-30200)" (GH-30208)
This reverts commit 2ef06d412531d1163dbc72877c88aedf3ed82a25.
files:
D Misc/NEWS.d/next/C API/2021-12-19-13-02-59.bpo-46131.ZBWQtO.rst
M Doc/c-api/typeobj.rst
M Include/floatobject.h
M Include/object.h
M Objects/floatobject.c
M Objects/typeobject.c
M Tools/gdb/libpython.py
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst
index eed2ac2c092ec..cd8723efef6bb 100644
--- a/Doc/c-api/typeobj.rst
+++ b/Doc/c-api/typeobj.rst
@@ -1145,7 +1145,6 @@ and :c:type:`PyType_Type` effectively act as defaults.)
.. XXX Document more flags here?
- .. data:: Py_TPFLAGS_FLOAT_SUBCLASS
.. data:: Py_TPFLAGS_LONG_SUBCLASS
.. data:: Py_TPFLAGS_LIST_SUBCLASS
.. data:: Py_TPFLAGS_TUPLE_SUBCLASS
diff --git a/Include/floatobject.h b/Include/floatobject.h
index 51be745e11cfa..3b6ca478eaef2 100644
--- a/Include/floatobject.h
+++ b/Include/floatobject.h
@@ -14,8 +14,6 @@ extern "C" {
PyAPI_DATA(PyTypeObject) PyFloat_Type;
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
-#define PyFloat_Check(op) \
- PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_FLOAT_SUBCLASS)
#define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type)
#ifdef Py_NAN
diff --git a/Include/object.h b/Include/object.h
index ee817a545a2b5..e5544e8b588ed 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -397,7 +397,6 @@ given type object has a specified feature.
#define _Py_TPFLAGS_MATCH_SELF (1UL << 22)
/* These flags are used to determine if a type is a subclass. */
-#define Py_TPFLAGS_FLOAT_SUBCLASS (1UL << 23)
#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24)
#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25)
#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26)
diff --git a/Misc/NEWS.d/next/C API/2021-12-19-13-02-59.bpo-46131.ZBWQtO.rst b/Misc/NEWS.d/next/C API/2021-12-19-13-02-59.bpo-46131.ZBWQtO.rst
deleted file mode 100644
index 08768ca594966..0000000000000
--- a/Misc/NEWS.d/next/C API/2021-12-19-13-02-59.bpo-46131.ZBWQtO.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Add a fast path for ``PyFloat_Check`` via a ``Py_TPFLAGS_FLOAT_SUBCLASS``
-flag.
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 37434f32bd995..f8620d6f8ef0b 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1959,7 +1959,6 @@ PyTypeObject PyFloat_Type = {
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
- Py_TPFLAGS_FLOAT_SUBCLASS |
_Py_TPFLAGS_MATCH_SELF, /* tp_flags */
float_new__doc__, /* tp_doc */
0, /* tp_traverse */
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 8bd92801da4ba..af35180cdb983 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -5783,9 +5783,6 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
else if (PyType_IsSubtype(base, &PyDict_Type)) {
type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS;
}
- else if (PyType_IsSubtype(base, &PyFloat_Type)) {
- type->tp_flags |= Py_TPFLAGS_FLOAT_SUBCLASS;
- }
if (PyType_HasFeature(base, _Py_TPFLAGS_MATCH_SELF)) {
type->tp_flags |= _Py_TPFLAGS_MATCH_SELF;
}
diff --git a/Tools/gdb/libpython.py b/Tools/gdb/libpython.py
index 41d1c3cc6e1bd..a0a95e3fc63cb 100755
--- a/Tools/gdb/libpython.py
+++ b/Tools/gdb/libpython.py
@@ -85,7 +85,6 @@ def _sizeof_void_p():
Py_TPFLAGS_MANAGED_DICT = (1 << 4)
Py_TPFLAGS_HEAPTYPE = (1 << 9)
-Py_TPFLAGS_FLOAT_SUBCLASS = (1 << 23)
Py_TPFLAGS_LONG_SUBCLASS = (1 << 24)
Py_TPFLAGS_LIST_SUBCLASS = (1 << 25)
Py_TPFLAGS_TUPLE_SUBCLASS = (1 << 26)
@@ -380,8 +379,6 @@ def subclass_from_type(cls, t):
if tp_flags & Py_TPFLAGS_HEAPTYPE:
return HeapTypeObjectPtr
- if tp_flags & Py_TPFLAGS_FLOAT_SUBCLASS:
- return PyFloatObjectPtr
if tp_flags & Py_TPFLAGS_LONG_SUBCLASS:
return PyLongObjectPtr
if tp_flags & Py_TPFLAGS_LIST_SUBCLASS:
@@ -913,16 +910,6 @@ class PyNoneStructPtr(PyObjectPtr):
def proxyval(self, visited):
return None
-class PyFloatObjectPtr(PyObjectPtr):
- _typename = 'PyFloatObject'
-
- def proxyval(self, visited):
- return self.field('ob_fval')
-
- def write_repr(self, out, visited):
- proxy = self.proxyval(visited)
- out.write("%s" % proxy)
-
class PyFrameObjectPtr(PyObjectPtr):
_typename = 'PyFrameObject'
More information about the Python-checkins
mailing list