def define_hash_varsized(self): S = lltype.GcStruct('S', ('abc', lltype.Signed), ('def', lltype.Array(lltype.Signed))) s = lltype.malloc(S, 3, zero=True) h_s = lltype.identityhash(s) def f(): return lltype.identityhash(s) - h_s # != 0 (so far), # because S is a varsized structure. return f
def hash_whatever(TYPE, x): # Hash of lltype object. # Only supports strings, unicodes and regular instances, # as well as primitives that can meaningfully be cast to Signed. if isinstance(TYPE, lltype.Ptr) and TYPE.TO._gckind == 'gc': if TYPE.TO is rstr.STR or TYPE.TO is rstr.UNICODE: return rstr.LLHelpers.ll_strhash(x) # assumed not null else: if x: return lltype.identityhash(x) else: return 0 else: return rffi.cast(lltype.Signed, x)
def op_gc_identityhash(self, obj): return lltype.identityhash(obj)
def _get_hash_(self): if self.value: return lltype.identityhash(self.value) else: return 0
def rd_hash(ref): assert ref return lltype.identityhash(ref)
def ll_my_gethash(ptr): return identityhash(ptr) # from lltype
def _ll_1_gc_identityhash(x): return lltype.identityhash(x)
def ll_inst_hash(ins): if not ins: return 0 # for None else: return lltype.identityhash(ins)
def ll_inst_hash(ins): if not ins: return 0 # for None else: from rpython.rtyper.lltypesystem import lltype return lltype.identityhash(ins)
def f(): return lltype.identityhash(s) - h_s # != 0 (so far),