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

Python listobject.W_ListObject类代码示例

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

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



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

示例1: test_extend_other_with_empty

 def test_extend_other_with_empty(self):
     space = self.space
     w = space.wrap
     l = W_ListObject(space, [w(1), w(2), w(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.extend(W_ListObject(space, []))
     assert isinstance(l.strategy, IntegerListStrategy)
开发者ID:Darriall,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py


示例2: test_float_to_any

 def test_float_to_any(self):
     l = W_ListObject(self.space, [self.space.wrap(1.1),self.space.wrap(2.2),self.space.wrap(3.3)])
     assert isinstance(l.strategy, FloatListStrategy)
     l.append(self.space.wrap(4.4))
     assert isinstance(l.strategy, FloatListStrategy)
     l.append(self.space.wrap("a"))
     assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:7,代码来源:test_liststrategies.py


示例3: test_setslice_int_range

 def test_setslice_int_range(self):
     space = self.space
     w = space.wrap
     l = W_ListObject(space, [w(1), w(2), w(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.setslice(0, 1, 2, make_range_list(space, 5, 1, 4))
     assert isinstance(l.strategy, IntegerListStrategy)
开发者ID:Darriall,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py


示例4: test_string_to_any

 def test_string_to_any(self):
     l = W_ListObject(self.space, [self.space.wrap('a'),self.space.wrap('b'),self.space.wrap('c')])
     assert isinstance(l.strategy, StringListStrategy)
     l.append(self.space.wrap('d'))
     assert isinstance(l.strategy, StringListStrategy)
     l.append(self.space.wrap(3))
     assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py


示例5: test_int_to_any

 def test_int_to_any(self):
     l = W_ListObject(self.space, [self.space.wrap(1),self.space.wrap(2),self.space.wrap(3)])
     assert isinstance(l.strategy, IntegerListStrategy)
     l.append(self.space.wrap(4))
     assert isinstance(l.strategy, IntegerListStrategy)
     l.append(self.space.wrap('a'))
     assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:7,代码来源:test_liststrategies.py


示例6: test_create_list_from_set

    def test_create_list_from_set(self):
        from pypy.objspace.std.setobject import W_SetObject
        from pypy.objspace.std.setobject import _initialize_set

        space = self.space
        w = space.wrap

        w_l = W_ListObject(space, [space.wrap(1), space.wrap(2), space.wrap(3)])

        w_set = W_SetObject(self.space)
        _initialize_set(self.space, w_set, w_l)
        w_set.iter = None # make sure fast path is used

        w_l2 = W_ListObject(space, [])
        space.call_method(w_l2, "__init__", w_set)

        w_l2.sort(False)
        assert space.eq_w(w_l, w_l2)

        w_l = W_ListObject(space, [space.wrap("a"), space.wrap("b"), space.wrap("c")])
        _initialize_set(self.space, w_set, w_l)

        space.call_method(w_l2, "__init__", w_set)

        w_l2.sort(False)
        assert space.eq_w(w_l, w_l2)
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:26,代码来源:test_liststrategies.py


示例7: test_unicode_to_any

 def test_unicode_to_any(self):
     space = self.space
     l = W_ListObject(space, [space.wrap(u'a'), space.wrap(u'b'), space.wrap(u'c')])
     assert isinstance(l.strategy, UnicodeListStrategy)
     l.append(space.wrap(u'd'))
     assert isinstance(l.strategy, UnicodeListStrategy)
     l.append(space.wrap(3))
     assert isinstance(l.strategy, ObjectListStrategy)
开发者ID:Darriall,项目名称:pypy,代码行数:8,代码来源:test_liststrategies.py


示例8: test_add_does_not_use_getitems

 def test_add_does_not_use_getitems(self):
     l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
     l1.getitems = None
     l2 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
     l2.getitems = None
     l3 = self.space.add(l1, l2)
     l4 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
     assert self.space.eq_w(l3, l4)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:8,代码来源:test_liststrategies.py


示例9: test_mul_does_not_clone

 def test_mul_does_not_clone(self):
     # only testing right mul at the moment
     w = self.space.wrap
     arg = w(2)
     w_lis = W_ListObject(self.space, [arg])
     w_lis.clone = None
     # does not crash
     self.space.mul(w_lis, w(5))
开发者ID:charred,项目名称:pypy,代码行数:8,代码来源:test_listobject.py


示例10: test_int_or_float_setslice_mixed_5

 def test_int_or_float_setslice_mixed_5(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
     w_l2 = W_ListObject(space, [space.wrap(32), space.wrap(45)])
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert isinstance(w_l2.strategy, IntegerListStrategy)
     w_l1.setslice(0, 1, 1, w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert space.unwrap(w_l1) == [32, 45, 1.2]
开发者ID:Qointum,项目名称:pypy,代码行数:9,代码来源:test_liststrategies.py


示例11: test_int_or_float_extend_mixed_6

 def test_int_or_float_extend_mixed_6(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(-2.5)])
     w_l2 = W_ListObject(space, [space.wrap(3.4), space.wrap(-2)])
     assert isinstance(w_l1.strategy, FloatListStrategy)
     assert isinstance(w_l2.strategy, IntOrFloatListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert space.unwrap(w_l1) == [-2.5, 3.4, -2]
开发者ID:Qointum,项目名称:pypy,代码行数:9,代码来源:test_liststrategies.py


示例12: test_int_or_float_extend

 def test_int_or_float_extend(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
     w_l2 = W_ListObject(space, [space.wrap(3), space.wrap(4.5)])
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert isinstance(w_l2.strategy, IntOrFloatListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert space.unwrap(w_l1) == [0, 1.2, 3, 4.5]
开发者ID:Qointum,项目名称:pypy,代码行数:9,代码来源:test_liststrategies.py


示例13: test_int_or_float_sort

 def test_int_or_float_sort(self):
     space = self.space
     w_l = W_ListObject(space, [space.wrap(1.2), space.wrap(1),
                                space.wrap(1.0), space.wrap(5)])
     w_l.sort(False)
     assert [(type(x), x) for x in space.unwrap(w_l)] == [
         (int, 1), (float, 1.0), (float, 1.2), (int, 5)]
     w_l.sort(True)
     assert [(type(x), x) for x in space.unwrap(w_l)] == [
         (int, 5), (float, 1.2), (int, 1), (float, 1.0)]
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py


示例14: test_int_or_float_extend_mixed_1

 def test_int_or_float_extend_mixed_1(self):
     space = self.space
     w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
     w_l2 = W_ListObject(space, [space.wrap(3)])
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert isinstance(w_l2.strategy, IntegerListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert [(type(x), x) for x in space.unwrap(w_l1)] == [
         (int, 0), (float, 1.2), (int, 3)]
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py


示例15: test_int_or_float_from_float

 def test_int_or_float_from_float(self):
     space = self.space
     w = space.wrap
     w_l = W_ListObject(space, [space.wrap(-42.5)])
     assert isinstance(w_l.strategy, FloatListStrategy)
     w_l.append(w(-15))
     assert isinstance(w_l.strategy, IntOrFloatListStrategy)
     assert space.float_w(w_l.getitem(0)) == -42.5
     assert space.int_w(w_l.getitem(1)) == -15
     assert space.len_w(w_l) == 2
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py


示例16: test_int_or_float_from_integer

 def test_int_or_float_from_integer(self):
     space = self.space
     w = space.wrap
     w_l = W_ListObject(space, [space.wrap(int(-2**31))])
     assert isinstance(w_l.strategy, IntegerListStrategy)
     w_l.append(w(-5.1))
     assert isinstance(w_l.strategy, IntOrFloatListStrategy)
     assert space.int_w(w_l.getitem(0)) == -2**31
     assert space.float_w(w_l.getitem(1)) == -5.1
     assert space.len_w(w_l) == 2
开发者ID:Qointum,项目名称:pypy,代码行数:10,代码来源:test_liststrategies.py


示例17: descr__new__

def descr__new__(space, w_listtype, __args__):
    if space.config.objspace.std.withmultilist:
        from pypy.objspace.std.listmultiobject import W_ListMultiObject
        w_obj = space.allocate_instance(W_ListMultiObject, w_listtype)
        W_ListMultiObject.__init__(w_obj, space)
    else:
        from pypy.objspace.std.listobject import W_ListObject
        w_obj = space.allocate_instance(W_ListObject, w_listtype)
        W_ListObject.__init__(w_obj, [])
    return w_obj
开发者ID:TheDunn,项目名称:flex-pypy,代码行数:10,代码来源:listtype.py


示例18: test_mul

    def test_mul(self):
        l1 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        l2 = l1.mul(2)
        l3 = W_ListObject(self.space, [self.space.wrap(1), self.space.wrap(2), self.space.wrap(3), self.space.wrap(1), self.space.wrap(2), self.space.wrap(3)])
        assert self.space.eq_w(l2, l3)

        l4 = make_range_list(self.space, 1, 1, 3)
        assert self.space.eq_w(l4, l1)

        l5 = l4.mul(2)
        assert self.space.eq_w(l5, l3)
开发者ID:craigkerstiens,项目名称:pypy,代码行数:11,代码来源:test_liststrategies.py


示例19: test_int_or_float_setslice_mixed_5_overflow

 def test_int_or_float_setslice_mixed_5_overflow(self):
     if sys.maxint == 2147483647:
         py.test.skip("only on 64-bit")
     space = self.space
     ovf1 = 2 ** 35
     w_l1 = W_ListObject(space, [space.wrap(0), space.wrap(1.2)])
     w_l2 = W_ListObject(space, [space.wrap(32), space.wrap(ovf1)])
     assert isinstance(w_l1.strategy, IntOrFloatListStrategy)
     assert isinstance(w_l2.strategy, IntegerListStrategy)
     w_l1.setslice(0, 1, 1, w_l2)
     assert isinstance(w_l1.strategy, ObjectListStrategy)
     assert space.unwrap(w_l1) == [32, ovf1, 1.2]
开发者ID:Qointum,项目名称:pypy,代码行数:12,代码来源:test_liststrategies.py


示例20: test_int_or_float_extend_mixed_5_overflow

 def test_int_or_float_extend_mixed_5_overflow(self):
     if sys.maxint == 2147483647:
         py.test.skip("only on 64-bit")
     space = self.space
     ovf1 = 2 ** 35
     w_l1 = W_ListObject(space, [space.wrap(-2.5)])
     w_l2 = W_ListObject(space, [space.wrap(ovf1)])
     assert isinstance(w_l1.strategy, FloatListStrategy)
     assert isinstance(w_l2.strategy, IntegerListStrategy)
     w_l1.extend(w_l2)
     assert isinstance(w_l1.strategy, ObjectListStrategy)
     assert space.unwrap(w_l1) == [-2.5, ovf1]
开发者ID:Qointum,项目名称:pypy,代码行数:12,代码来源:test_liststrategies.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python longobject.W_LongObject类代码示例发布时间:2022-05-27
下一篇:
Python listobject.make_range_list函数代码示例发布时间: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