def func(no): m = mmap.mmap(no, size*4096) m.unmap_range(left*4096, (right-left)*4096) m.read(1) m.seek(right*4096) m.read(1) def in_map(m, offset): return rffi.ptradd(m.data, offset) def as_num(ptr): return rffi.cast(lltype.Unsigned, ptr) res = mmap.alloc_hinted(in_map(m, (left+right)/2 * 4096), 4096) assert as_num(in_map(m, left*4096)) <= as_num(res) < as_num(in_map(m, right*4096))