Esempio n. 1
0
 def compares_by_identity(w_self):
     from pypy.objspace.descroperation import object_hash, type_eq
     if not w_self.space.config.objspace.std.withidentitydict:
         return False # conservative
     #
     if w_self.compares_by_identity_status != UNKNOWN:
         # fast path
         return w_self.compares_by_identity_status == COMPARES_BY_IDENTITY
     #
     default_hash = object_hash(w_self.space)
     my_eq = w_self.lookup('__eq__')
     overrides_eq = (my_eq and my_eq is not type_eq(w_self.space))
     overrides_eq_cmp_or_hash = (overrides_eq or
                                 w_self.lookup('__hash__') is not default_hash)
     if overrides_eq_cmp_or_hash:
         w_self.compares_by_identity_status = OVERRIDES_EQ_CMP_OR_HASH
     else:
         w_self.compares_by_identity_status = COMPARES_BY_IDENTITY
     return w_self.compares_by_identity_status == COMPARES_BY_IDENTITY