Re: [Python-Dev] ctypes, memory mapped files and context manager

2017-01-08 Thread eryk sun
On Sun, Jan 8, 2017 at 8:25 AM, Armin Rigo wrote: > > c_raw = ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)(lambda p: p) Use ctypes.addressof. > addr = c_raw(ctypes.pointer(T.from_buffer(m))) > b = ctypes.cast(addr, ctypes.POINTER(T)).contents ctypes.cast uses an FFI call. In

Re: [Python-Dev] ctypes, memory mapped files and context manager

2017-01-08 Thread Armin Rigo
Hi Hans-Peter, On 6 January 2017 at 00:28, Hans-Peter Jansen wrote: > Leaves the question, how stable this "interface" is? Another way to jump through hoops: c_raw = ctypes.PYFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)(lambda p: p) addr = c_raw(ctypes.pointer(T.from_buffer(m))) b =