[issue39310] Add math.ulp(x): unit in the last place

Mark Dickinson report at bugs.python.org
Wed Jan 15 04:31:57 EST 2020


Mark Dickinson <dickinsm at gmail.com> added the comment:

[Brett]

> Can I just say that "ulp" is totally non-obvious what that even means unless you have a specific math background?

It's a good point. I guess we have a choice between using the domain-specific standard-ish name (which should be immediately meaningful to experts, but doesn't give much of a hint to non-experts) or using something more descriptive (which then risks confusing experts until they figure out "oh, that's just ulp").

There's also the option of spelling it out as "unit_in_last_place", but I'm not sure that benefits anyone.

For meaningful descriptive names, "float_resolution" or "gap_to_next" are about the best I can come up with. "precision" is too ambiguous.

NumPy has "numpy.spacing". But this exhibits exactly the trap of *not* using the "ulp" name: on a first glance, I incorrectly decided that NumPy *didn't* implement a ulp function. Then, having found `numpy.spacing`, I had to read the description carefully in order to recognise that "oh, this is just ulp". (Actually, I had to do more, since the description doesn't make all the corner cases clear, and in fact is currently wrong for powers of 2.)

If we can get people can coalesce around a preferred alternative name, we could consider changing this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39310>
_______________________________________


More information about the Python-bugs-list mailing list