from m1n1.setup import * def roundtrip(data): with u.heap.guarded_malloc(4 * 1024 * 1024) as scratch: scratch0 = scratch scratch1 = scratch + 2 * 1024 * 1024 iface.writemem(scratch0, data) p.memcpy32(scratch1, scratch0, len(data)) return iface.readmem(scratch1, len(data)) for i in range(128): data = os.urandom(1024 * 1024) data_back = roundtrip(data) print(i, data == data_back)