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

Terry Reedy tjreedy at udel.edu
Wed Mar 30 22:24:28 CEST 2011


On 3/30/2011 2:54 PM, Mark Dickinson wrote:
> On Wed, Mar 30, 2011 at 7:37 PM, Eli Stevens (Gmail)
> <wickedgrey at gmail.com>  wrote:
>> What would be required to get a float16 data type added to PEP 3118

To start, email the two authors.

>> (either implicitly via inclusion of the struct module, or explicitly
>> in the PEP itself)?
>
> Hmm.  A partial list of requirements:
>
> (1) An open bugs.python.org issue.

If this were added to the PEP, it would be included in
http://bugs.python.org/issue3132

> (2) Someone to provide patches (it sounds like you're up for this).

Or do a review of Meador Inge's latest (last January) patch version.

> (3) Someone else willing to review those patches (this is the hard part).
> (4) General agreement in the b.p.o. issue that this is a worthwhile
> feature to include;  a disagreement here would punt the issue back
> into python-dev or python-ideas territory for wider discussion.
>
> It probably doesn't make sense to try to update the PEP itself:

See above.

 > just propose the addition to the struct module in an issue.
>
> Work on the struct part of PEP 3118 is somewhat stalled at the moment;
>   I had assigned some of those issues to myself, but unassigned them
> after finding I didn't really have proper time to think about them.
> If you could help out with some of the other open PEP 3118 issues,
> that might go a long way towards persuading someone to review your
> changes.

I think that a patch to _struct.py should include all the 3118 
additions, and not just this one.

Searching All Test 'pep 3118' on the tracker returns 7 open issues.

> For myself, I have mixed feelings on the proposed addition:  while I
> can see how the half-precision floats would be useful in NumPy, it's
> not so clear that they'd be useful to Python itself.  It feels a
> little bit odd to have NumPy driving Python additions that may not be
> of that much interest to non-NumPy users.

I am pretty sure both extended slices and Ellipsis were first added for 
Numpy's ancestor Numerical Python. In any case, the intent of the pep 
seems to be that struct be expanded to match NumPy.

"Additions to the struct string-syntax
The struct string-syntax is missing some characters to fully implement 
data-format descriptions already available elsewhere (in ctypes and 
NumPy for example)."

Some of the additions (such as pointers) already seem less useful than 
float16, which I presume struct would just expand to (or compress from) 
a normal, usable, Python float.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list