Martin Panter added the comment: In Python 3.5 (since Issue 15944), you can now cast normal C-contiguous memoryviews (including ones from ctypes) to bytes:
>>> a = (ctypes.c_double * 3)(1,2,3) >>> m = memoryview(a) >>> m.format '<d' >>> byteview = m.cast("B") >>> byteview.format 'B' >>> byteview[0] 0 Also, the format has changed at some point. See '<d' above vs '(3)<d' from David’s original post. Maybe it would be nice for ctypes to use a proper struct module format string where possible, but there doesn’t seem to be much demand. ---------- components: +ctypes nosy: +martin.panter _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue16132> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com