本文整理汇总了Python中pypy.rlib.objectmodel.compute_unique_id函数的典型用法代码示例。如果您正苦于以下问题:Python compute_unique_id函数的具体用法?Python compute_unique_id怎么用?Python compute_unique_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了compute_unique_id函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dump_storage
def dump_storage(logname, storage, liveboxes):
"For profiling only."
import os
from pypy.rlib import objectmodel
assert logname is not None # annotator hack
fd = os.open(logname, os.O_WRONLY | os.O_APPEND | os.O_CREAT, 0666)
os.write(fd, 'Log(%d, [\n' % objectmodel.compute_unique_id(storage))
frameinfo = storage.rd_frame_info_list
while True:
os.write(fd, '\t("%s", %d, %d) at %xd,\n' % (
frameinfo.jitcode, frameinfo.pc, frameinfo.exception_target,
objectmodel.compute_unique_id(frameinfo)))
frameinfo = frameinfo.prev
if frameinfo is None:
break
os.write(fd, '\t],\n\t[\n')
numb = storage.rd_numb
while True:
os.write(fd, '\t\t%s at %xd,\n' % ([untag(i) for i in numb.nums],
objectmodel.compute_unique_id(numb)))
numb = numb.prev
if numb is None:
break
os.write(fd, '\t], [\n')
for const in storage.rd_consts:
os.write(fd, '\t"%s",\n' % (const.repr_rpython(),))
os.write(fd, '\t], [\n')
for box in liveboxes:
os.write(fd, '\t"%s",\n' % (box.repr_rpython(),))
os.write(fd, '\t], [\n')
if storage.rd_virtuals is not None:
for virtual in storage.rd_virtuals:
os.write(fd, '\t%s,\n' % (virtual.repr_rpython(),))
os.write(fd, '\t])\n')
os.close(fd)
示例2: run_once
def run_once():
a = A()
ida = compute_unique_id(a)
b = B()
idb = compute_unique_id(b)
c = C()
idc = compute_unique_id(c)
llop.gc__collect(lltype.Void)
llop.gc__collect(lltype.Void)
llop.gc__collect(lltype.Void)
return ida, idb, idc
示例3: fn
def fn(n):
id_prebuilt1 = compute_unique_id(u.x)
if n > 0:
x = BoxedObject(n)
else:
x = UnboxedObject(n)
id_x1 = compute_unique_id(x)
rgc.collect() # check that a prebuilt tagged pointer doesn't explode
id_prebuilt2 = compute_unique_id(u.x)
id_x2 = compute_unique_id(x)
print u.x, id_prebuilt1, id_prebuilt2
print x, id_x1, id_x2
return ((id_x1 == id_x2) * 1 +
(id_prebuilt1 == id_prebuilt2) * 10 +
(id_x1 != id_prebuilt1) * 100)
示例4: f
def f():
from pypy.rpython.lltypesystem import lltype, rffi
alist = [A() for i in range(50)]
idarray = lltype.malloc(rffi.INTP.TO, len(alist), flavor='raw')
# Compute the id of all the elements of the list. The goal is
# to not allocate memory, so that if the GC needs memory to
# remember the ids, it will trigger some collections itself
i = 0
while i < len(alist):
idarray[i] = compute_unique_id(alist[i])
i += 1
j = 0
while j < 2:
if j == 1: # allocate some stuff between the two iterations
[A() for i in range(20)]
i = 0
while i < len(alist):
assert idarray[i] == compute_unique_id(alist[i])
i += 1
j += 1
lltype.free(idarray, flavor='raw')
示例5: fn
def fn():
return (compute_unique_id("foo"),
compute_unique_id(u"bar"),
compute_unique_id([1]),
compute_unique_id({"foo": 3}),
compute_unique_id(StringBuilder()),
compute_unique_id(UnicodeBuilder()))
示例6: func
def func():
a2 = A()
a3 = A()
id1 = compute_unique_id(a1)
id2 = compute_unique_id(a2)
id3 = compute_unique_id(a3)
llop.gc__collect(lltype.Void)
error = 0
if id1 != compute_unique_id(a1): error += 1
if id2 != compute_unique_id(a2): error += 2
if id3 != compute_unique_id(a3): error += 4
return error
示例7: unique_id
def unique_id(self, space):
if self.user_overridden_class:
return W_Object.unique_id(self, space)
return space.wrap(compute_unique_id(space.str_w(self)))
示例8: id__ANY
def id__ANY(space, w_obj):
# print 'id:', w_obj
return space.wrap(objectmodel.compute_unique_id(w_obj))
示例9: immutable_unique_id
def immutable_unique_id(self, space):
if self.user_overridden_class:
return None
return space.wrap(compute_unique_id(space.unicode_w(self)))
示例10: externfn
def externfn(node):
llop.debug_print(lltype.Void, compute_unique_id(node),
node.value, node.extra)
return node.value * 2
示例11: externalfn
def externalfn(n):
if n > 1000:
return compute_unique_id(exctx.topframeref())
return 1
示例12: method___id__
def method___id__(self, space):
return space.newint(compute_unique_id(self))
示例13: getids
def getids(i, j):
e1 = ExampleClass(1)
e2 = ExampleClass(2)
a = [e1, e2][i]
b = [e1, e2][j]
return (compute_unique_id(a) == compute_unique_id(b)) == (a is b)
示例14: repr_rpython
def repr_rpython(box, typechars):
return '%s/%s%d' % (box._get_hash_(), typechars,
compute_unique_id(box))