summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-11-08 16:44:44 (GMT)
committerGitHub <noreply@github.com>2024-11-08 16:44:44 (GMT)
commitfa4092259763ffad45a5bb9ef55f515dc6a69ad2 (patch)
tree2a37522fd4bef93f3fbce649bc3396c58ca4f130 /Objects
parentfd5580cd151e07c690e9d7594513be5fa3102a2e (diff)
downloadcpython-fa4092259763ffad45a5bb9ef55f515dc6a69ad2.zip
cpython-fa4092259763ffad45a5bb9ef55f515dc6a69ad2.tar.gz
cpython-fa4092259763ffad45a5bb9ef55f515dc6a69ad2.tar.bz2
GH-126547: Pre-assign version numbers for a few common classes (GH-126551)
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c1
-rw-r--r--Objects/bytesobject.c1
-rw-r--r--Objects/complexobject.c1
-rw-r--r--Objects/dictobject.c1
-rw-r--r--Objects/floatobject.c1
-rw-r--r--Objects/listobject.c1
-rw-r--r--Objects/longobject.c1
-rw-r--r--Objects/setobject.c2
-rw-r--r--Objects/tupleobject.c1
-rw-r--r--Objects/typeobject.c4
10 files changed, 13 insertions, 1 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index fd2a85a..5a52b2f 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2452,6 +2452,7 @@ PyTypeObject PyByteArray_Type = {
PyType_GenericAlloc, /* tp_alloc */
PyType_GenericNew, /* tp_new */
PyObject_Free, /* tp_free */
+ .tp_version_tag = _Py_TYPE_VERSION_BYTEARRAY,
};
/*********************** Bytearray Iterator ****************************/
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index dcc1aba..ac02cfe 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -3080,6 +3080,7 @@ PyTypeObject PyBytes_Type = {
bytes_alloc, /* tp_alloc */
bytes_new, /* tp_new */
PyObject_Free, /* tp_free */
+ .tp_version_tag = _Py_TYPE_VERSION_BYTES,
};
void
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 787235c..7b4948f 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -1250,4 +1250,5 @@ PyTypeObject PyComplex_Type = {
PyType_GenericAlloc, /* tp_alloc */
actual_complex_new, /* tp_new */
PyObject_Free, /* tp_free */
+ .tp_version_tag = _Py_TYPE_VERSION_COMPLEX,
};
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index f28a926..2090008 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -4912,6 +4912,7 @@ PyTypeObject PyDict_Type = {
dict_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
.tp_vectorcall = dict_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_DICT,
};
/* For backward compatibility with old dictionary interface */
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 7e14a8a..f00b6a6 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1916,6 +1916,7 @@ PyTypeObject PyFloat_Type = {
0, /* tp_alloc */
float_new, /* tp_new */
.tp_vectorcall = (vectorcallfunc)float_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_FLOAT,
};
static void
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 930aefd..bb0040c 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -3774,6 +3774,7 @@ PyTypeObject PyList_Type = {
PyType_GenericNew, /* tp_new */
PyObject_GC_Del, /* tp_free */
.tp_vectorcall = list_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_LIST,
};
/*********************** List Iterator **************************/
diff --git a/Objects/longobject.c b/Objects/longobject.c
index 4e94894..b4c0f63 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -6584,6 +6584,7 @@ PyTypeObject PyLong_Type = {
long_new, /* tp_new */
PyObject_Free, /* tp_free */
.tp_vectorcall = long_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_INT,
};
static PyTypeObject Int_InfoType;
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 2671792..955ccbe 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -2520,6 +2520,7 @@ PyTypeObject PySet_Type = {
set_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
.tp_vectorcall = set_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_SET,
};
/* frozenset object ********************************************************/
@@ -2610,6 +2611,7 @@ PyTypeObject PyFrozenSet_Type = {
frozenset_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
.tp_vectorcall = frozenset_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_FROZEN_SET,
};
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index f3132e0..193914d 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -909,6 +909,7 @@ PyTypeObject PyTuple_Type = {
tuple_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
.tp_vectorcall = tuple_vectorcall,
+ .tp_version_tag = _Py_TYPE_VERSION_TUPLE,
};
/* The following function breaks the notion that tuples are immutable:
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 88db29e..4af7f02 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -8613,7 +8613,9 @@ init_static_type(PyInterpreterState *interp, PyTypeObject *self,
self->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
assert(NEXT_GLOBAL_VERSION_TAG <= _Py_MAX_GLOBAL_TYPE_VERSION_TAG);
- _PyType_SetVersion(self, NEXT_GLOBAL_VERSION_TAG++);
+ if (self->tp_version_tag == 0) {
+ _PyType_SetVersion(self, NEXT_GLOBAL_VERSION_TAG++);
+ }
}
else {
assert(!initial);