Here is an example of what I try to do:
import ctypes
MEM_SIZE = 1024*1024*128
# allocate memory (this is Windows specific)
ptr = ctypes.cdll.msvcrt.malloc(MEM_SIZE)
# make memory accessible to Python calls
mem = ctypes.string_at(ptr, MEM_SIZE)
# BAD: string_at duplicates memory
# store it to disk
open(r'test.raw', 'wb').write(mem)
In a nutshell: I have a plain memory pointer, I know the size of the block and want to store it on disk or reuse it as a numpy array.
How can I do that without generating a copy of the memory block?
Related question: stackoverflow: Fill python ctypes pointer (thanks to Brian Larsen for the hint)