This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author martin.panter
Recipients BreamoreBoy, amaury.forgeotdarc, belopolsky, dabeaz, martin.panter, meador.inge
Date 2016-06-09.04:56:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1465448171.55.0.48965975468.issue16132@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-06-09 04:56:11martin.pantersetrecipients: + martin.panter, amaury.forgeotdarc, belopolsky, meador.inge, dabeaz, BreamoreBoy
2016-06-09 04:56:11martin.pantersetmessageid: <1465448171.55.0.48965975468.issue16132@psf.upfronthosting.co.za>
2016-06-09 04:56:11martin.panterlinkissue16132 messages
2016-06-09 04:56:11martin.pantercreate