本文整理汇总了Python中pypy.rlib.objectmodel.r_dict函数的典型用法代码示例。如果您正苦于以下问题:Python r_dict函数的具体用法?Python r_dict怎么用?Python r_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_dict函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: f
def f(n):
d = r_dict(myeq, myhash)
for i in range(10):
d[i] = i*i
try:
return d[n]
except FooError:
return 99
开发者ID:enyst,项目名称:plexnet,代码行数:8,代码来源:test_basic.py
示例2: f
def f():
d1 = r_dict(eq, raising_hash)
d1['xxx'] = 1
try:
d1["blabla"] = 2
except TypeError:
return 42
return 0
开发者ID:ieure,项目名称:pypy,代码行数:8,代码来源:test_typed.py
示例3: make_setdata_from_w_iterable
def make_setdata_from_w_iterable(space, w_iterable=None):
data = r_dict(space.eq_w, space.hash_w)
if w_iterable is not None:
w_iterator = space.iter(w_iterable)
while True:
try:
w_item = space.next(w_iterator)
except OperationError, e:
if not e.match(space, space.w_StopIteration):
raise
break
data[w_item] = None
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:12,代码来源:setobject.py
示例4: test_customdict_circular
def test_customdict_circular(self):
from pypy.rlib.objectmodel import r_dict
def key_eq(a, b):
return a.x[0] == b.x[0]
def key_hash(a):
return ord(a.x[0])
class A:
def __init__(self, x):
self.x = x
a = A('foo')
a.dict = r_dict(key_eq, key_hash)
a.dict[a] = 42
def fn(b):
if b:
s = A('foo')
else:
s = A('bar')
return a.dict[s]
assert self.interpret(fn, [True]) == 42
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:20,代码来源:constant.py
示例5: test_constant_r_dict
def test_constant_r_dict(self):
def strange_key_eq(key1, key2):
return key1[0] == key2[0] # only the 1st character is relevant
def strange_key_hash(key):
return ord(key[0])
d = r_dict(strange_key_eq, strange_key_hash)
d['hello'] = 42
d['world'] = 43
for x in range(65, 91):
d[chr(x)] = x*x
def func(i):
return d[chr(i)]
res = self.interpret(func, [ord('h')])
assert res == 42
res = self.interpret(func, [ord('w')])
assert res == 43
for x in range(65, 91):
res = self.interpret(func, [x])
assert res == x*x
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:20,代码来源:test_rconstantdict.py
示例6: __init__
def __init__(self, transitions=None):
if transitions is None:
transitions = []
self.transitions = transitions
self._states_cache = r_dict(state_eq, state_hash)
开发者ID:bivab,项目名称:pytri,代码行数:5,代码来源:petri_net.py
示例7: new_ref_dict_2
def new_ref_dict_2(self):
return r_dict(rd_eq, rd_hash)
开发者ID:enyst,项目名称:plexnet,代码行数:2,代码来源:typesystem.py
示例8: oof
def oof():
d = r_dict(strange_key_eq, strange_key_hash)
d['x'] = 42
return d['x']
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:4,代码来源:test_oortype.py
示例9: __init__
def __init__(w_self, space, setdata=None):
if setdata is None:
w_self.setdata = r_dict(space.eq_w, space.hash_w)
else:
w_self.setdata = setdata.copy()
开发者ID:enyst,项目名称:plexnet,代码行数:5,代码来源:setobject.py
示例10: make_setdata_from_w_iterable
def make_setdata_from_w_iterable(space, w_iterable=None):
data = r_dict(space.eq_w, space.hash_w)
if w_iterable is not None:
for w_item in space.viewiterable(w_iterable):
data[w_item] = None
return data
开发者ID:enyst,项目名称:plexnet,代码行数:6,代码来源:setobject.py
示例11: initialize_as_rdict
def initialize_as_rdict(self):
assert self.r_dict_content is None
self.r_dict_content = r_dict(self.space.eq_w, self.space.hash_w)
return self.r_dict_content
开发者ID:alkorzt,项目名称:pypy,代码行数:4,代码来源:dictmultiobject.py
示例12: get_printable_location
def get_printable_location(shapelen, sig):
return 'numpy ' + sig.debug_repr() + ' [%d dims,%s]' % (shapelen, driver_name)
return get_printable_location
def sigeq(one, two):
return one.eq(two)
def sigeq_no_numbering(one, two):
""" Cache for iterator numbering should not compare array numbers
"""
return one.eq(two, compare_array_no=False)
def sighash(sig):
return sig.hash()
known_sigs = r_dict(sigeq, sighash)
def find_sig(sig, arr):
sig.invent_array_numbering(arr)
try:
return known_sigs[sig]
except KeyError:
sig.invent_numbering()
known_sigs[sig] = sig
return sig
def _add_ptr_to_cache(ptr, cache):
i = 0
for p in cache:
if ptr == p:
return i
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:31,代码来源:signature.py
示例13: dict_equal_consts
def dict_equal_consts():
"NOT_RPYTHON"
# Returns a dict in which Consts that compare as equal
# are identified when used as keys.
return r_dict(dc_eq, dc_hash)
开发者ID:jerroldgao,项目名称:pypy,代码行数:5,代码来源:history.py
示例14: ll_set_functions
def ll_set_functions(self, sm_eq, sm_hash):
"NOT_RPYTHON"
key_eq = sm_eq._callable
key_hash = sm_hash._callable
self._dict = objectmodel.r_dict(key_eq, key_hash)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:5,代码来源:ootype.py
示例15: new_cache
def new_cache():
return r_dict(sigeq_no_numbering, sighash)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:2,代码来源:signature.py
示例16: __init__
def __init__(w_self, space, w_otherdict=None):
if w_otherdict is None:
w_self.content = r_dict(space.eq_w, space.hash_w)
else:
w_self.content = w_otherdict.content.copy()
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:5,代码来源:dictobject.py
示例17: __init__
def __init__(self, space):
self.space = space
self.content = r_dict(space.eq_w, space.hash_w)
self.info = DictInfo()
self.thing_with_del = OnTheWayOut(self.info)
开发者ID:alkorzt,项目名称:pypy,代码行数:5,代码来源:dictmultiobject.py
注:本文中的pypy.rlib.objectmodel.r_dict函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论