@@ -231,26 +231,22 @@ do_richcompare(PyObject *v, PyObject *w, int op)
231
231
PyObject * res ;
232
232
int checked_reverse_op = 0 ;
233
233
234
- /* GraalPy change: in the following, we replaced any 'Py_TYPE(v)' by
235
- 'v_type' and any 'Py_TYPE(w)' by 'w_type' to save some calls. */
236
- const PyTypeObject * v_type = Py_TYPE (v );
237
- const PyTypeObject * w_type = Py_TYPE (w );
238
- if (v_type != w_type &&
239
- PyType_IsSubtype (w_type , v_type ) &&
240
- (f = w_type -> tp_richcompare ) != NULL ) {
234
+ if (!Py_IS_TYPE (v , Py_TYPE (w )) &&
235
+ PyType_IsSubtype (Py_TYPE (w ), Py_TYPE (v )) &&
236
+ (f = Py_TYPE (w )-> tp_richcompare ) != NULL ) {
241
237
checked_reverse_op = 1 ;
242
238
res = (* f )(w , v , _Py_SwappedOp [op ]);
243
239
if (res != Py_NotImplemented )
244
240
return res ;
245
241
Py_DECREF (res );
246
242
}
247
- if ((f = v_type -> tp_richcompare ) != NULL ) {
243
+ if ((f = Py_TYPE ( v ) -> tp_richcompare ) != NULL ) {
248
244
res = (* f )(v , w , op );
249
245
if (res != Py_NotImplemented )
250
246
return res ;
251
247
Py_DECREF (res );
252
248
}
253
- if (!checked_reverse_op && (f = w_type -> tp_richcompare ) != NULL ) {
249
+ if (!checked_reverse_op && (f = Py_TYPE ( w ) -> tp_richcompare ) != NULL ) {
254
250
res = (* f )(w , v , _Py_SwappedOp [op ]);
255
251
if (res != Py_NotImplemented )
256
252
return res ;
@@ -269,8 +265,8 @@ do_richcompare(PyObject *v, PyObject *w, int op)
269
265
PyErr_Format (PyExc_TypeError ,
270
266
"'%s' not supported between instances of '%.100s' and '%.100s'" ,
271
267
opstrings [op ],
272
- v_type -> tp_name ,
273
- w_type -> tp_name );
268
+ Py_TYPE ( v ) -> tp_name ,
269
+ Py_TYPE ( w ) -> tp_name );
274
270
return NULL ;
275
271
}
276
272
Py_INCREF (res );
0 commit comments