• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python baseobjspace.ObjSpace类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pypy.interpreter.baseobjspace.ObjSpace的典型用法代码示例。如果您正苦于以下问题:Python ObjSpace类的具体用法?Python ObjSpace怎么用?Python ObjSpace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ObjSpace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: delslice

 def delslice(self, w_obj, w_start, w_stop):
     w_descr = self.lookup(w_obj, '__delslice__')
     if w_descr is not None:
         w_start, w_stop = old_slice_range(self, w_obj, w_start, w_stop)
         self.get_and_call_function(w_descr, w_obj, w_start, w_stop)
     else:
         ObjSpace.delslice(self, w_obj, w_start, w_stop)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:7,代码来源:objspace.py


示例2: __init__

    def __init__(self, config=None):
        self._seen_extras = []
        ObjSpace.__init__(self, config=config)
        self.setup()

        # Be sure to annotate W_SliceObject constructor.
        # In Python2, this is triggered by W_InstanceObject.__getslice__.
        def build_slice():
            self.newslice(self.w_None, self.w_None, self.w_None)
        self._seen_extras.append(build_slice)
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:objspace.py


示例3: exception_match

 def exception_match(self, w_exc_type, w_check_class):
     try:
         check_class = self.unwrap(w_check_class)
     except UnwrapException:
         raise Exception, "non-constant except guard"
     if not isinstance(check_class, tuple):
         # the simple case
         return ObjSpace.exception_match(self, w_exc_type, w_check_class)
     # checking a tuple of classes
     for w_klass in self.viewiterable(w_check_class):
         if ObjSpace.exception_match(self, w_exc_type, w_klass):
             return True
     return False
开发者ID:AishwaryaKM,项目名称:python-tutorial,代码行数:13,代码来源:objspace.py


示例4: call_method

    def call_method(self, w_obj, methname, *arg_w):
        if self.config.objspace.opcodes.CALL_METHOD:
            from pypy.objspace.std.callmethod import call_method_opt

            return call_method_opt(self, w_obj, methname, *arg_w)
        else:
            return ObjSpace.call_method(self, w_obj, methname, *arg_w)
开发者ID:,项目名称:,代码行数:7,代码来源:


示例5: createexecutioncontext

 def createexecutioncontext(self):
     # add space specific fields to execution context
     # note that this method must not call space methods that might need an
     # execution context themselves (e.g. nearly all space methods)
     ec = ObjSpace.createexecutioncontext(self)
     ec._py_repr = None
     return ec
开发者ID:,项目名称:,代码行数:7,代码来源:


示例6: listview

 def listview(self, w_obj, expected_length=-1):
     t = self.listview_no_unpack(w_obj)
     if t is None:
         return 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 t
开发者ID:yuyichao,项目名称:pypy,代码行数:7,代码来源:objspace.py


示例7: fixedview

 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)
开发者ID:,项目名称:,代码行数:17,代码来源:


示例8: exception_issubclass_w

def exception_issubclass_w(space, w_cls1, w_cls2):
    if isinstance(w_cls1, W_ClassObject):
        if isinstance(w_cls2, W_ClassObject):
            return w_cls1.is_subclass_of(w_cls2)
        return False
    if isinstance(w_cls2, W_ClassObject):
        return False
    return BaseObjSpace.exception_issubclass_w(space, w_cls1, w_cls2)
开发者ID:Darriall,项目名称:pypy,代码行数:8,代码来源:abstractinst.py


示例9: finditem

    def finditem(self, w_obj, w_key):
        """ Perform a getitem on w_obj with w_key (any object). Returns found
        element or None on element not found.

        performance shortcut to avoid creating the OperationError(KeyError).
        """
        if isinstance(w_obj, W_DictMultiObject) and not w_obj.user_overridden_class:
            return w_obj.getitem(w_key)
        return ObjSpace.finditem(self, w_obj, w_key)
开发者ID:mozillazg,项目名称:pypy,代码行数:9,代码来源:objspace.py


示例10: fixedview

 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)
开发者ID:mozillazg,项目名称:pypy,代码行数:18,代码来源:objspace.py


示例11: listview

 def listview(self, w_obj, expected_length=-1):
     if isinstance(w_obj, W_ListObject):
         t = w_obj.wrappeditems
     elif isinstance(w_obj, W_TupleObject):
         t = w_obj.wrappeditems[:]
     else:
         return 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 t
开发者ID:,项目名称:,代码行数:10,代码来源:


示例12: exception_issubclass_w

def exception_issubclass_w(space, w_cls1, w_cls2):
    cls1 = space.interpclass_w(w_cls1)
    cls2 = space.interpclass_w(w_cls2)
    if isinstance(cls1, W_ClassObject):
        if isinstance(cls2, W_ClassObject):
            return cls1.is_subclass_of(cls2)
        return False
    if isinstance(cls2, W_ClassObject):
        return False
    return BaseObjSpace.exception_issubclass_w(space, w_cls1, w_cls2)
开发者ID:alkorzt,项目名称:pypy,代码行数:10,代码来源:abstractinst.py


示例13: exception_match

 def exception_match(self, w_exc_type, w_check_class):
     try:
         check_class = self.unwrap(w_check_class)
     except UnwrapException:
         raise Exception, "non-constant except guard"
     if check_class in (NotImplementedError, AssertionError):
         raise error.FlowingError("Catching %s is not valid in RPython" % check_class.__name__)
     if not isinstance(check_class, tuple):
         # the simple case
         return ObjSpace.exception_match(self, w_exc_type, w_check_class)
     # special case for StackOverflow (see rlib/rstackovf.py)
     if check_class == rstackovf.StackOverflow:
         w_real_class = self.wrap(rstackovf._StackOverflow)
         return ObjSpace.exception_match(self, w_exc_type, w_real_class)
     # checking a tuple of classes
     for w_klass in self.fixedview(w_check_class):
         if self.exception_match(w_exc_type, w_klass):
             return True
     return False
开发者ID:are-prabhu,项目名称:pypy,代码行数:19,代码来源:objspace.py


示例14: unpackiterable

 def unpackiterable(self, w_obj, expected_length=-1):
     if isinstance(w_obj, W_TupleObject):
         t = w_obj.wrappeditems[:]
     elif isinstance(w_obj, W_ListObject):
         t = w_obj.wrappeditems[:]
     else:
         return ObjSpace.unpackiterable(self, w_obj, expected_length)
     if expected_length != -1 and len(t) != expected_length:
         raise UnpackValueError("Expected length %d, got %d" % (expected_length, len(t)))
     return t
开发者ID:,项目名称:,代码行数:10,代码来源:


示例15: finditem_str

    def finditem_str(self, w_obj, key):
        """ Perform a getitem on w_obj with key (string). Returns found
        element or None on element not found.

        performance shortcut to avoid creating the OperationError(KeyError)
        and allocating W_BytesObject
        """
        if isinstance(w_obj, W_DictMultiObject) and not w_obj.user_overridden_class:
            return w_obj.getitem_str(key)
        return ObjSpace.finditem_str(self, w_obj, key)
开发者ID:mozillazg,项目名称:pypy,代码行数:10,代码来源:objspace.py


示例16: fixedview

 def fixedview(self, w_obj, expected_length=-1):
     """ Fast paths
     """
     if isinstance(w_obj, W_TupleObject):
         t = w_obj.wrappeditems
     elif isinstance(w_obj, W_ListObject):
         t = w_obj.wrappeditems[:]
     else:
         return ObjSpace.fixedview(self, w_obj, expected_length)
     if expected_length != -1 and len(t) != expected_length:
         raise UnpackValueError("Expected length %d, got %d" % (expected_length, len(t)))
     return t
开发者ID:alkorzt,项目名称:pypy,代码行数:12,代码来源:objspace.py


示例17: getindex_w

 def getindex_w(self, w_obj, w_exception, objdescr=None):
     # Performance shortcut for the common case of w_obj being an int.
     # If withsmallint is disabled, we check for W_IntObject.
     # If withsmallint is enabled, we only check for W_SmallIntObject - it's
     # probably not useful to have a shortcut for W_IntObject at all then.
     if self.config.objspace.std.withsmallint:
         if type(w_obj) is W_SmallIntObject:
             return w_obj.intval
     else:
         if type(w_obj) is W_IntObject:
             return w_obj.intval
     return ObjSpace.getindex_w(self, w_obj, w_exception, objdescr)
开发者ID:antoine1fr,项目名称:pygirl,代码行数:12,代码来源:objspace.py


示例18: createexecutioncontext

 def createexecutioncontext(self):
     # add space specific fields to execution context
     ec = ObjSpace.createexecutioncontext(self)
     ec._py_repr = self.newdict()
     if self.config.objspace.std.withmethodcache:
         SIZE = 1 << self.config.objspace.std.methodcachesizeexp
         ec.method_cache_versions = [None] * SIZE
         ec.method_cache_names = [None] * SIZE
         ec.method_cache_lookup_where = [(None, None)] * SIZE
         if self.config.objspace.std.withmethodcachecounter:
             ec.method_cache_hits = {}
             ec.method_cache_misses = {}
     return ec
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:13,代码来源:objspace.py


示例19: createexecutioncontext

 def createexecutioncontext(self):
     # add space specific fields to execution context
     # note that this method must not call space methods that might need an
     # execution context themselves (e.g. nearly all space methods)
     ec = ObjSpace.createexecutioncontext(self)
     ec._py_repr = None
     if self.config.objspace.std.withmethodcache:
         SIZE = 1 << self.config.objspace.std.methodcachesizeexp
         ec.method_cache_versions = [None] * SIZE
         ec.method_cache_names = [None] * SIZE
         ec.method_cache_lookup_where = [(None, None)] * SIZE
         if self.config.objspace.std.withmethodcachecounter:
             ec.method_cache_hits = {}
             ec.method_cache_misses = {}
     return ec
开发者ID:antoine1fr,项目名称:pygirl,代码行数:15,代码来源:objspace.py


示例20: unpackiterable

 def unpackiterable(self, w_iterable, expected_length=None):
     if not isinstance(w_iterable, Variable):
         l = list(self.unwrap(w_iterable))
         if expected_length is not None and len(l) != expected_length:
             raise ValueError
         return [self.wrap(x) for x in l]
     if isinstance(w_iterable, Variable) and expected_length is None:
         raise UnwrapException, ("cannot unpack a Variable iterable" "without knowing its length")
     elif expected_length is not None:
         w_len = self.len(w_iterable)
         w_correct = self.eq(w_len, self.wrap(expected_length))
         if not self.is_true(w_correct):
             e = OperationError(self.w_ValueError, self.w_None)
             e.normalize_exception(self)
             raise e
         return [self.do_operation("getitem", w_iterable, self.wrap(i)) for i in range(expected_length)]
     return ObjSpace.unpackiterable(self, w_iterable, expected_length)
开发者ID:are-prabhu,项目名称:pypy,代码行数:17,代码来源:objspace.py



注:本文中的pypy.interpreter.baseobjspace.ObjSpace类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python error.oefmt函数代码示例发布时间:2022-05-27
下一篇:
Python argument.Arguments类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap