[Python-ideas] Adding a half-float (16-bit) type to PEP 3118 (and possibly the struct module?)

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Mar 31 17:52:16 CEST 2011

On Wed, Mar 30, 2011 at 3:02 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
> On Wed, Mar 30, 2011 at 7:54 PM, Alexander Belopolsky
> <alexander.belopolsky at gmail.com> wrote:
>> I would like to see a patch adding float16 to struct and ctypes
>> modules together with the buffer support.
> I'm not sure how much sense this makes for ctypes, given that float16
> isn't a datatype supported by most C implementations.

"On ARM targets, GCC supports half-precision (16-bit) floating point
via the __fp16 type."


However, before ctypes can support this, half-floats' support should
be added to libffi through platform specific assembly hackery.  So I
withdraw my suggestion that ctypes support should be a prerequisite
for float16 support in the buffer protocol, but I still would like to
see it in struct.

BTW, what letter code is proposed for half-floats?  The only
unassigned letter in the word "half" is 'a'.  Maybe it is time to
extend struct and buffer format specification to include field

More information about the Python-ideas mailing list