当前位置: 首页>>代码示例>>Python>>正文


Python baseobjspace.ObjSpace类代码示例

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


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


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