@@ -43,9 +43,7 @@ class object "PyObject *" "&PyBaseObject_Type"
43
43
PyUnicode_IS_READY(name) && \
44
44
(PyUnicode_GET_LENGTH(name) <= MCACHE_MAX_ATTR_SIZE)
45
45
46
- // bpo-42745: next_version_tag remains shared by all interpreters because of static types
47
- // Used to set PyTypeObject.tp_version_tag
48
- static unsigned int next_version_tag = 1 ;
46
+ #define next_version_tag (_PyRuntime.types.next_version_tag)
49
47
50
48
typedef struct PySlot_Offset {
51
49
short subslot_offset ;
@@ -5828,7 +5826,8 @@ static PyObject *
5828
5826
object___reduce_ex___impl (PyObject * self , int protocol )
5829
5827
/*[clinic end generated code: output=2e157766f6b50094 input=f326b43fb8a4c5ff]*/
5830
5828
{
5831
- static PyObject * objreduce ;
5829
+ #define objreduce \
5830
+ (_Py_INTERP_CACHED_OBJECT(_PyInterpreterState_Get(), objreduce))
5832
5831
PyObject * reduce , * res ;
5833
5832
5834
5833
if (objreduce == NULL ) {
@@ -5864,6 +5863,7 @@ object___reduce_ex___impl(PyObject *self, int protocol)
5864
5863
}
5865
5864
5866
5865
return _common_reduce (self , protocol );
5866
+ #undef objreduce
5867
5867
}
5868
5868
5869
5869
static PyObject *
@@ -8524,8 +8524,6 @@ __ne__ etc. all map to tp_richcompare) and one name may map to multiple slots
8524
8524
an all-zero entry.
8525
8525
*/
8526
8526
8527
- typedef struct wrapperbase slotdef ;
8528
-
8529
8527
#undef TPSLOT
8530
8528
#undef FLSLOT
8531
8529
#undef AMSLOT
@@ -8574,7 +8572,7 @@ typedef struct wrapperbase slotdef;
8574
8572
ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \
8575
8573
#NAME "($self, value, /)\n--\n\n" DOC)
8576
8574
8577
- static slotdef slotdefs [] = {
8575
+ static pytype_slotdef slotdefs [] = {
8578
8576
TPSLOT (__getattribute__ , tp_getattr , NULL , NULL , "" ),
8579
8577
TPSLOT (__getattr__ , tp_getattr , NULL , NULL , "" ),
8580
8578
TPSLOT (__setattr__ , tp_setattr , NULL , NULL , "" ),
@@ -8799,12 +8797,6 @@ slotptr(PyTypeObject *type, int ioffset)
8799
8797
return (void * * )ptr ;
8800
8798
}
8801
8799
8802
- /* Length of array of slotdef pointers used to store slots with the
8803
- same __name__. There should be at most MAX_EQUIV-1 slotdef entries with
8804
- the same __name__, for any __name__. Since that's a static property, it is
8805
- appropriate to declare fixed-size arrays for this. */
8806
- #define MAX_EQUIV 10
8807
-
8808
8800
/* Return a slot pointer for a given name, but ONLY if the attribute has
8809
8801
exactly one slot function. The name must be an interned string. */
8810
8802
static void * *
@@ -8813,9 +8805,10 @@ resolve_slotdups(PyTypeObject *type, PyObject *name)
8813
8805
/* XXX Maybe this could be optimized more -- but is it worth it? */
8814
8806
8815
8807
/* pname and ptrs act as a little cache */
8816
- static PyObject * pname ;
8817
- static slotdef * ptrs [MAX_EQUIV ];
8818
- slotdef * p , * * pp ;
8808
+ PyInterpreterState * interp = _PyInterpreterState_Get ();
8809
+ #define pname _Py_INTERP_CACHED_OBJECT(interp, type_slots_pname)
8810
+ #define ptrs _Py_INTERP_CACHED_OBJECT(interp, type_slots_ptrs)
8811
+ pytype_slotdef * p , * * pp ;
8819
8812
void * * res , * * ptr ;
8820
8813
8821
8814
if (pname != name ) {
@@ -8842,6 +8835,8 @@ resolve_slotdups(PyTypeObject *type, PyObject *name)
8842
8835
res = ptr ;
8843
8836
}
8844
8837
return res ;
8838
+ #undef pname
8839
+ #undef ptrs
8845
8840
}
8846
8841
8847
8842
@@ -8899,8 +8894,8 @@ resolve_slotdups(PyTypeObject *type, PyObject *name)
8899
8894
* When done, return a pointer to the next slotdef with a different offset,
8900
8895
* because that's convenient for fixup_slot_dispatchers(). This function never
8901
8896
* sets an exception: if an internal error happens (unlikely), it's ignored. */
8902
- static slotdef *
8903
- update_one_slot (PyTypeObject * type , slotdef * p )
8897
+ static pytype_slotdef *
8898
+ update_one_slot (PyTypeObject * type , pytype_slotdef * p )
8904
8899
{
8905
8900
PyObject * descr ;
8906
8901
PyWrapperDescrObject * d ;
@@ -9015,7 +9010,7 @@ update_one_slot(PyTypeObject *type, slotdef *p)
9015
9010
static int
9016
9011
update_slots_callback (PyTypeObject * type , void * data )
9017
9012
{
9018
- slotdef * * pp = (slotdef * * )data ;
9013
+ pytype_slotdef * * pp = (pytype_slotdef * * )data ;
9019
9014
for (; * pp ; pp ++ ) {
9020
9015
update_one_slot (type , * pp );
9021
9016
}
@@ -9026,9 +9021,9 @@ update_slots_callback(PyTypeObject *type, void *data)
9026
9021
static int
9027
9022
update_slot (PyTypeObject * type , PyObject * name )
9028
9023
{
9029
- slotdef * ptrs [MAX_EQUIV ];
9030
- slotdef * p ;
9031
- slotdef * * pp ;
9024
+ pytype_slotdef * ptrs [MAX_EQUIV ];
9025
+ pytype_slotdef * p ;
9026
+ pytype_slotdef * * pp ;
9032
9027
int offset ;
9033
9028
9034
9029
assert (PyUnicode_CheckExact (name ));
@@ -9065,15 +9060,15 @@ static void
9065
9060
fixup_slot_dispatchers (PyTypeObject * type )
9066
9061
{
9067
9062
assert (!PyErr_Occurred ());
9068
- for (slotdef * p = slotdefs ; p -> name ; ) {
9063
+ for (pytype_slotdef * p = slotdefs ; p -> name ; ) {
9069
9064
p = update_one_slot (type , p );
9070
9065
}
9071
9066
}
9072
9067
9073
9068
static void
9074
9069
update_all_slots (PyTypeObject * type )
9075
9070
{
9076
- slotdef * p ;
9071
+ pytype_slotdef * p ;
9077
9072
9078
9073
/* Clear the VALID_VERSION flag of 'type' and all its subclasses. */
9079
9074
PyType_Modified (type );
@@ -9244,7 +9239,7 @@ static int
9244
9239
add_operators (PyTypeObject * type )
9245
9240
{
9246
9241
PyObject * dict = type -> tp_dict ;
9247
- slotdef * p ;
9242
+ pytype_slotdef * p ;
9248
9243
PyObject * descr ;
9249
9244
void * * ptr ;
9250
9245
0 commit comments