@@ -11601,7 +11601,7 @@ static pytype_slotdef slotdefs[] = {
1160111601/* Stores the number of times where slotdefs has elements with same name.
1160211602 This counter precalculated by _PyType_InitSlotDefs() when the main
1160311603 interpreter starts. */
11604- static uint8_t slotdefs_name_counts [Py_ARRAY_LENGTH (slotdefs )];
11604+ static uint8_t slotdefs_dups [Py_ARRAY_LENGTH (slotdefs )][ 1 + MAX_EQUIV ];
1160511605
1160611606/* Given a type pointer and an offset gotten from a slotdef entry, return a
1160711607 pointer to the actual slot. This is not quite the same as simply adding
@@ -11768,11 +11768,22 @@ update_one_slot(PyTypeObject *type, pytype_slotdef *p, pytype_slotdef **next_p,
1176811768 ((PyWrapperDescrObject * )descr )-> d_base -> name_strobj == p -> name_strobj ) {
1176911769 void * * tptr ;
1177011770 size_t index = (p - slotdefs );
11771- if (slotdefs_name_counts [index ] == 1 ) {
11772- tptr = slotptr (type , p -> offset );
11771+ if (slotdefs_dups [index ][0 ] > 1 ) {
11772+ tptr = NULL ;
11773+ for (size_t i = 1 ; i <= slotdefs_dups [index ][0 ]; i ++ ) {
11774+ pytype_slotdef * q = & slotdefs [slotdefs_dups [index ][i ]];
11775+ void * * qptr = slotptr (type , q -> offset );
11776+ if (qptr == NULL || * qptr == NULL )
11777+ continue ;
11778+ if (tptr != NULL ) {
11779+ tptr = NULL ;
11780+ break ;
11781+ }
11782+ tptr = qptr ;
11783+ }
1177311784 }
1177411785 else {
11775- tptr = NULL ;
11786+ tptr = slotptr ( type , offset ) ;
1177611787 }
1177711788
1177811789 if (tptr == NULL || tptr == ptr )
@@ -12034,7 +12045,7 @@ _PyType_InitSlotDefs(PyInterpreterState *interp)
1203412045 Py_CLEAR (bytearray );
1203512046 }
1203612047
12037- memset (slotdefs_name_counts , 0 , sizeof (slotdefs_name_counts ));
12048+ memset (slotdefs_dups , -1 , sizeof (slotdefs_dups ));
1203812049
1203912050 Py_ssize_t pos = 0 ;
1204012051 PyObject * key = NULL ;
@@ -12044,7 +12055,7 @@ _PyType_InitSlotDefs(PyInterpreterState *interp)
1204412055 uint8_t n = data [0 ];
1204512056 for (uint8_t i = 0 ; i < n ; i ++ ) {
1204612057 uint8_t idx = data [i + 1 ];
12047- slotdefs_name_counts [idx ] = n ;
12058+ memcpy ( & slotdefs_dups [idx ], data , sizeof ( uint8_t ) * ( n + 1 )) ;
1204812059 }
1204912060 }
1205012061
0 commit comments