On Wed, 2025-12-10 at 09:26 +0100, Ralf Gommers via NumPy-Discussion wrote: > On Sun, Nov 23, 2025 at 11:51 AM Ralf Gommers > <[email protected]> > wrote: > > > > > > > On Sun, Nov 23, 2025 at 8:47 AM Matti Picus via NumPy-Discussion < > > [email protected]> wrote: > > > > > > > > > > The question I have is whether we should expose all the > > functionality > > that's currently exposed in `halffloat.h` or leave out some of the > > odd > > ones. The conversion and comparison functions seem most useful, but > > for > > example the `*_nonan` variants look weird (we don't normally expose > > "skip-nan" flavors just for some performance), as does `_iszero` > > (unlike > > `_isnan` et al. it doesn't have a C99 equivalent). > > > > Now that the header-only version in > https://github.com/numpy/numpy/pull/30380 is close to merge-ready, > I'd like > to circle back to this point - what will we expose as the new public > API? A > 1:1 replacement for everything is ready, but if we expose it all > under the > new `npy_float16_*` names then we'll be stuck with it in the future. > We can > also decide to just expose the conversion and comparison routines, > plus the > macros, but leave out the `*_nonan` routines, `_iszero`, and possibly > also > the low-level bit conversion routines like > `npy_floatbits_to_float16bits`. > They could just be ifdef'd out and in case someone needs them, it'll > be > quite easy to expose them in a next release. > > Thoughts? >
Ah, I half expected more math functions (that just cast to float), but it seems that is actually only `divmod` (which I would say we can safely drop). FWIW, I think the conversion functions are the truly important ones, after that I find it a bit hard to make a cut. Especially if we include comparisons, utilities like `isnan`/`isfinite` and maybe `nextafter` seem reasonable (and I suspect very simple code wise, some of these might even be used by the comparisons/conversions). At that point that is a large chunk of what is there... If we just look to thin out a bit: `spacing` isn't C99 and I agree that at least the `_nonan` versions seem fine to drop. The bit-level conversions seem ok to drop, although I wouldn't be surprised if they are used more than the normal conversions. - Sebastian > Cheers, > Ralf > _______________________________________________ > NumPy-Discussion mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3//lists/numpy-discussion.python.org > Member address: [email protected] _______________________________________________ NumPy-Discussion mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/numpy-discussion.python.org Member address: [email protected]
