Edward Loper <edloper at gradient.cis.upenn.edu> writes: >> Edward Loper <edloper at gradient.cis.upenn.edu> writes: >> >>>This means that 'nan' is no longer a well-behaved dictionary key: >>> >>> >>> x = {float('nan'):0} >>> >>> x[float('nan')] = 1 >>> >>> print x >>> {nan: 0, nan: 1} >>> >>>Even worse, we get different behavior if we use the "same copy" of nan: >>> >>> >>> nan = float('nan') >>> >>> x = {nan:0} >>> >>> x[nan] = 1 >>> >>> print x >>> {nan: 1} >> Gah. Still, I think this is more a theoretical objection than >> anything else? [...] >> I have at no point claimed that I have given Python 2.4 a coherent >> ieee 754 floating point story. All I have tried to do is /reduce/ the >> level of surprise knocking around, and I think I've succeeded. If >> someone (not me!) has the time and energy to do a 'proper job' (and >> I'd expect working out what that means to be the hard part), then you >> have my support and pre-emptive thanks. > > Tim Delaney's suggestion [1] seemed pretty reasonable. In particular: > > - Ensure that NaN is a singleton (like True and False). I.e., the > float constructor checks if the float is NaN, and if so returns a > singleton. And we do that... how, exactly? > Advantages: > - We have an easy way to test if a variable is nan: "x is NaN" There's (potentially, at least) more than one NaN (QNaN & SNaN, f'ex). > - nan will work "properly" as a dictionary key BFD. > The important question is whether this would slow down other > operations. As for cmp(), my understanding was that it should just > return -1 if two unordered objects are not equal. Then I believe your understanding is flawed. >>> cmp(2,1) 1 Without wanting to sound patronizing or rude -- but risking it anyway -- you're not giving the impression of understanding these issues any more than I do, and I *know* I don't understand them well enough to get them straight. Cheers, mwh -- > say-hi-to-the-flying-pink-elephants-for-me-ly y'rs, No way, the flying pink elephants are carrying MACHINE GUNS! Aiiee!! Time for a kinder, gentler hallucinogen... -- Barry Warsaw & Greg Ward, python-dev
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4