【发布时间】:2016-12-03 12:33:53
【问题描述】:
如果一个对象是可变的,那么可以通过不指定 buffer() 的第二个参数来获得一个可修改的缓冲区(这是一个内置函数),如下所示:
>>> s = bytearray(1000000) # a million zeroed bytes
>>> t = buffer(s, 1) # slice cuts off the first byte
>>> s[1] = 5 # set the second element in s
>>> t[0] # which is now also the first element in t!
'\x05'
但是,就我而言,我需要指定0x7fffffff作为大小参数。在这种情况下:
>>> b = buffer(bytearray('a'), 1,0x7fffffff)
how to make b writeable without copying it’s data?在我的情况下,_ctypessupport 已禁用,并且该程序未以 root 身份启动。
当然,可以使用 memoryview 之类的东西,但我失去了读取每个虚拟地址的内存的可能性。
【问题讨论】:
标签: python linux security python-2.x 32-bit