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

Python rmmap.mmap函数代码示例

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

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



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

示例1: func

 def func(no):
     m = mmap.mmap(no, 6, access=mmap.ACCESS_READ)
     m = mmap.mmap(no, 6, access=mmap.ACCESS_WRITE)
     m.write_byte("x")
     m.seek(0)
     assert m.read(6) == "xoobar"
     m.close()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:7,代码来源:test_rmmap.py


示例2: func

 def func():
     m = mmap.mmap(-1, 1000, tagname="foo")
     # same tagname, but larger size
     try:
         m2 = mmap.mmap(-1, 5000, tagname="foo")
         m2.getitem(4500)
     except WindowsError:
         pass
     m.close()
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:9,代码来源:test_rmmap.py


示例3: test_windows_crasher_1

    def test_windows_crasher_1(self):
        if sys.platform != "win32":
            skip("Windows-only test")

        m = mmap.mmap(-1, 1000, tagname="foo")
        # same tagname, but larger size
        try:
            m2 = mmap.mmap(-1, 5000, tagname="foo")
            m2.getitem(4500)
        except WindowsError:
            pass
        m.close()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:12,代码来源:test_rmmap.py


示例4: do_allocation_in_far_regions

def do_allocation_in_far_regions():
    """On 32 bits: this reserves 1.25GB of address space, or 2.5GB on Linux,
       which helps test this module for address values that are signed or
       unsigned.

       On 64-bits: reserves 10 times 2GB of address space.  This should help
       to find 32-vs-64-bit issues in the JIT.  It is likely that objects
       are further apart than 32 bits can represent; it is also possible
       to hit the corner case of being precisely e.g. 2GB - 8 bytes apart.

       Avoid this function if your OS reserves actual RAM from mmap() eagerly.
    """
    global far_regions
    if not far_regions:
        from pypy.rlib import rmmap
        if sys.maxint > 0x7FFFFFFF:
            PIECESIZE = 0x80000000
        else:
            if sys.platform == 'linux':
                PIECESIZE = 0x10000000
            else:
                PIECESIZE = 0x08000000
        PIECES = 10
        m = rmmap.mmap(-1, PIECES * PIECESIZE,
                       rmmap.MAP_PRIVATE|rmmap.MAP_ANONYMOUS|rmmap.MAP_NORESERVE,
                       rmmap.PROT_READ|rmmap.PROT_WRITE)
        m.close = lambda : None    # leak instead of giving a spurious
                                   # error at CPython's shutdown
        m._ll2ctypes_pieces = []
        for i in range(PIECES):
            m._ll2ctypes_pieces.append((i * PIECESIZE, (i+1) * PIECESIZE))
        far_regions = m
开发者ID:gorakhargosh,项目名称:pypy,代码行数:32,代码来源:ll2ctypes.py


示例5: mmap

    def mmap(space, fileno, length, flags=rmmap.MAP_SHARED,
        prot=rmmap.PROT_WRITE | rmmap.PROT_READ, access=rmmap._ACCESS_DEFAULT):

        try:
            return space.wrap(W_MMap(space, rmmap.mmap(fileno, length,
                                                       flags, prot, access)))
        except OSError, e:
            raise wrap_oserror(space, e, 'w_EnvironmentError')
开发者ID:antoine1fr,项目名称:pygirl,代码行数:8,代码来源:interp_mmap.py


示例6: func

 def func(no):
     m = mmap.mmap(no, 7)
     assert m.find("b") == 3
     assert m.find("z") == -1
     assert m.find("o", 5) == -1
     assert m.find("ob") == 2
     assert m.find("\0") == 6
     m.close()
开发者ID:alkorzt,项目名称:pypy,代码行数:8,代码来源:test_rmmap.py


示例7: mmap

 def mmap(space, w_subtype, fileno, length, tagname="",
          access=rmmap._ACCESS_DEFAULT, offset=0):
     self = space.allocate_instance(W_MMap, w_subtype)
     try:
         W_MMap.__init__(self, space,
                         rmmap.mmap(fileno, length, tagname, access,
                                    offset))
     except OSError, e:
         raise mmap_error(space, e)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:9,代码来源:interp_mmap.py


示例8: test_write_readonly

 def test_write_readonly(self):
     if os.name == "nt":
         skip("Needs PROT_READ")
     f = open(self.tmpname + "l", "w+")
     f.write("foobar")
     f.flush()
     m = mmap.mmap(f.fileno(), 6, prot=mmap.PROT_READ)
     raises(RTypeError, m.write, "foo")
     f.close()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:9,代码来源:test_rmmap.py


示例9: test_write_without_protwrite

 def test_write_without_protwrite(self):
     if os.name == "nt":
         skip("Needs PROT_WRITE")
     f = open(self.tmpname + "l2", "w+")
     f.write("foobar")
     f.flush()
     m = mmap.mmap(f.fileno(), 6, prot=~mmap.PROT_WRITE)
     raises(RTypeError, m.write_byte, 'a')
     raises(RTypeError, m.write, "foo")
     m.close()
     f.close()
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:11,代码来源:test_rmmap.py


示例10: test_windows_crasher_2

    def test_windows_crasher_2(self):
        if sys.platform != "win32":
            skip("Windows-only test")

        f = open(self.tmpname + "t", "w+")
        f.write("foobar")
        f.flush()

        f = open(self.tmpname + "t", "r+b")
        m = mmap.mmap(f.fileno(), 0)
        f.close()
        raises(WindowsError, m.resize, 0)
        raises(RValueError, m.getitem, 0)
        m.close()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:14,代码来源:test_rmmap.py


示例11: test_find_rfind

    def test_find_rfind(self):
        f = open(self.tmpname + "g", "w+")
        f.write("foobarfoobar\0")
        f.flush()
        m = mmap.mmap(f.fileno(), 13)

        for s1 in range(-20, 20):
            for e1 in range(-20, 20):
                expected = "foobarfoobar\0".find("ob", s1, e1)
                assert m.find("ob", s1, e1, False) == expected
                expected = "foobarfoobar\0".rfind("ob", s1, e1)
                assert m.find("ob", s1, e1, True) == expected

        m.close()
        f.close()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:15,代码来源:test_rmmap.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python rope.multiply函数代码示例发布时间:2022-05-27
下一篇:
Python rgc.collect函数代码示例发布时间: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