On Sun, Jul 5, 2020 at 10:04 PM Christopher Barker
Since you brought that up -- I recall a lot of debate about whether NaN's should be considered missing values or "poisoning" in the statistics module -- there are arguments for both, and neither was clear or obvious. So using NaN to mean "not specified" in this context would not be obvious to everyone, and when we have the perfectly good None instead, why do it?
Well, yes... I wrote a lot of that debate :-) I even sort of re-discovered quick select on my own... then eventually figured out that a bunch of people had benchmarked a better implementation to potentially use in statistics.median() a year before I tried. Python sorted() is really fast! But it's still the WRONG way to do this, or at least there should be a switch to allow nan-poisoning and/or nan-stripping. Btw, definitely +1 on math.clamp(value, *, lower=None, upper=None) .
what about:
math.clamp(value, *, lower=-math.inf, upper=math.inf) .
Oh sure. That's fine. But the implementation would still need to check for None and convert it to the infinities. Ordinary users just simply ARE going to try: math.clamp(x, lower=None, upper=99) And expect that to mean "I don't care about lower bound." -- The dead increasingly dominate and strangle both the living and the not-yet born. Vampiric capital and undead corporate persons abuse the lives and control the thoughts of homo faber. Ideas, once born, become abortifacients against new conceptions.