本文整理汇总了Python中pypy.interpreter.baseobjspace.ObjSpace.unpackiterable_unroll方法的典型用法代码示例。如果您正苦于以下问题:Python ObjSpace.unpackiterable_unroll方法的具体用法?Python ObjSpace.unpackiterable_unroll怎么用?Python ObjSpace.unpackiterable_unroll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pypy.interpreter.baseobjspace.ObjSpace
的用法示例。
在下文中一共展示了ObjSpace.unpackiterable_unroll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fixedview
# 需要导入模块: from pypy.interpreter.baseobjspace import ObjSpace [as 别名]
# 或者: from pypy.interpreter.baseobjspace.ObjSpace import unpackiterable_unroll [as 别名]
def fixedview(self, w_obj, expected_length=-1, unroll=False):
""" Fast paths
"""
if isinstance(w_obj, W_TupleObject):
t = w_obj.wrappeditems
elif isinstance(w_obj, W_ListObject):
t = w_obj.wrappeditems[:]
else:
if unroll:
return make_sure_not_resized(ObjSpace.unpackiterable_unroll(
self, w_obj, expected_length)[:])
else:
return make_sure_not_resized(ObjSpace.unpackiterable(
self, w_obj, expected_length)[:])
if expected_length != -1 and len(t) != expected_length:
raise self._wrap_expected_length(expected_length, len(t))
return make_sure_not_resized(t)
示例2: fixedview
# 需要导入模块: from pypy.interpreter.baseobjspace import ObjSpace [as 别名]
# 或者: from pypy.interpreter.baseobjspace.ObjSpace import unpackiterable_unroll [as 别名]
def fixedview(self, w_obj, expected_length=-1, unroll=False):
""" Fast paths
"""
if isinstance(w_obj, W_AbstractTupleObject) and self._uses_tuple_iter(w_obj):
t = w_obj.tolist()
elif type(w_obj) is W_ListObject:
if unroll:
t = w_obj.getitems_unroll()
else:
t = w_obj.getitems_fixedsize()
else:
if unroll:
return make_sure_not_resized(ObjSpace.unpackiterable_unroll(self, w_obj, expected_length))
else:
return make_sure_not_resized(ObjSpace.unpackiterable(self, w_obj, expected_length)[:])
if expected_length != -1 and len(t) != expected_length:
raise self._wrap_expected_length(expected_length, len(t))
return make_sure_not_resized(t)