On Mon, Apr 17, 2017 at 5:58 PM, Rob Gaddi <rgaddi@highlandtechnology.invalid> wrote: > buffertype = c_uint8 * size > return addressof(buffertype.from_buffer(buf, offset)) > > works but is inefficient and woefully inelegant.
A lot of the cost there is in creating buffertype, but why do you need that? You can use c_char.from_buffer if all you need is the base address. import ctypes def addressof_buffer(buf): return ctypes.addressof(ctypes.c_char.from_buffer(buf)) >>> b = bytearray(b'spam') >>> addressof_buffer(b) 2619159025048 >>> ctypes.string_at(2619159025048, 5) b'spam\x00' -- https://mail.python.org/mailman/listinfo/python-list