@@ -225,6 +225,19 @@ static int (*original_TypeCheck)(HPyContext *ctx, HPy h, HPy type);
225
225
static void (* original_Close )(HPyContext * ctx , HPy h );
226
226
static HPy (* original_UnicodeFromWideChar )(HPyContext * ctx , const wchar_t * arr , HPy_ssize_t size );
227
227
static HPy (* original_TupleFromArray )(HPyContext * ctx , HPy * items , HPy_ssize_t nitems );
228
+ static int (* original_Is )(HPyContext * ctx , HPy a , HPy b );
229
+
230
+ static int augment_Is (HPyContext * ctx , HPy a , HPy b ) {
231
+ long bitsA = toBits (a );
232
+ long bitsB = toBits (b );
233
+ if (bitsA == bitsB ) {
234
+ return 1 ;
235
+ } else if (isBoxedHandle (bitsA ) && isBoxedHandle (bitsB )) {
236
+ return original_Is (ctx , a , b );
237
+ } else {
238
+ return 0 ;
239
+ }
240
+ }
228
241
229
242
static void * augment_AsStruct (HPyContext * ctx , HPy h ) {
230
243
uint64_t bits = toBits (h );
@@ -455,6 +468,9 @@ void initDirectFastPaths(HPyContext *context) {
455
468
456
469
original_TupleFromArray = context -> ctx_Tuple_FromArray ;
457
470
context -> ctx_Tuple_FromArray = augment_TupleFromArray ;
471
+
472
+ original_Is = context -> ctx_Is ;
473
+ context -> ctx_Is = augment_Is ;
458
474
}
459
475
460
476
void setHPyContextNativeSpace (HPyContext * context , void * * nativeSpace ) {
0 commit comments