python的快速、无拷贝缓冲区
zero_buffer的Python项目详细描述
zero_buffer是一个高性能的零拷贝实现 python的字节缓冲区。
Documentation在readthedocs上可用。
fromzero_bufferimportBuffer# Create a buffer which has space for 8192 bytes.b=Buffer.allocate(8192)withopen(path,"rb")asf:# Read up to 8192 bytes from the file into the bufferb.read_from(f.fileno())# Create a read-only view of the buffer, this performs no copying.view=b.view()# Split the view on colons, this returns a generator which yields sub-views# of the view.forpartinview.split(b":"):print(part)
zero_buffer适用于python 2.6、2.7、3.2、3.3和pypy。