예제 #1
0
 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
예제 #2
0
 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
예제 #3
0
def hash_whatever(TYPE, x):
    # Hash of lltype or ootype 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
    elif TYPE is ootype.String or TYPE is ootype.Unicode:
        return x.ll_hash()
    elif isinstance(TYPE, ootype.OOType):
        if x:
            return ootype.identityhash(x)
        else:
            return 0
    else:
        return rffi.cast(lltype.Signed, x)
예제 #4
0
def hash_whatever(TYPE, x):
    # Hash of lltype or ootype 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
    elif TYPE is ootype.String or TYPE is ootype.Unicode:
        return x.ll_hash()
    elif isinstance(TYPE, ootype.OOType):
        if x:
            return ootype.identityhash(x)
        else:
            return 0
    else:
        return rffi.cast(lltype.Signed, x)
예제 #5
0
def _ll_1_gc_identityhash(x):
    return lltype.identityhash(x)
예제 #6
0
 def f():
     return lltype.identityhash(s) - h_s    # != 0 (so far),
예제 #7
0
파일: history.py 프로젝트: jerroldgao/pypy
 def _get_hash_(self):
     if self.value:
         return lltype.identityhash(self.value)
     else:
         return 0
예제 #8
0
 def f():
     return lltype.identityhash(s) - h_s    # != 0 (so far),
예제 #9
0
파일: test_basic.py 프로젝트: enyst/plexnet
 def f():
     obj1 = lltype.malloc(A)
     obj2 = lltype.malloc(A)
     return lltype.identityhash(obj1) == lltype.identityhash(obj2)
예제 #10
0
def rd_hash(ref):
    assert ref
    return lltype.identityhash(ref)
예제 #11
0
 def _get_hash_(self):
     if self.value:
         return lltype.identityhash(self.value)
     else:
         return 0
예제 #12
0
파일: support.py 프로젝트: neurobcn/plexnet
def _ll_1_gc_identityhash(x):
    return lltype.identityhash(x)
예제 #13
0
def ll_inst_hash(ins):
    if not ins:
        return 0    # for None
    else:
        from pypy.rpython.lltypesystem import lltype
        return lltype.identityhash(ins)     # also works for ootype
예제 #14
0
파일: rclass.py 프로젝트: xx312022850/pypy
def ll_inst_hash(ins):
    if not ins:
        return 0    # for None
    else:
        from pypy.rpython.lltypesystem import lltype
        return lltype.identityhash(ins)     # also works for ootype
예제 #15
0
 def f():
     obj1 = lltype.malloc(A)
     obj2 = lltype.malloc(A)
     return lltype.identityhash(obj1) == lltype.identityhash(obj2)