[Python-Dev] PyObject_RichCompareBool identity shortcut (original) (raw)
Steven D'Aprano steve at pearwood.info
Thu Apr 28 19:25:08 CEST 2011
- Previous message: [Python-Dev] PyObject_RichCompareBool identity shortcut
- Next message: [Python-Dev] PyObject_RichCompareBool identity shortcut
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alexander Belopolsky wrote:
With the status quo in Python, it may only make sense to store NaNs in array.array, but not in a list.
That's a bit extreme. It only gets you into trouble if you reason like this:
a = b = [1, 2, 3, float('nan')] if a == b: ... for x,y in zip(a,b): ... assert x==y ... Traceback (most recent call last): File "", line 3, in AssertionError
But it's perfectly fine to do this:
sum(a) nan
exactly as expected. Prohibiting NANs from lists is massive overkill for a small (alleged) problem.
I know thousands of words have been spilled on this, including many by myself, but I really believe this discussion is mostly bike-shedding. Given the vehemence of some replies, and the volume of talk, anyone would think that you could hardly write a line of Python code without badly tripping over problems caused by NANs. The truth is, I think, that most people will never see one in real world code, and those who are least likely to come across them are the most likely to be categorically against them.
(I grant that Alexander is an exception -- I understand that he does do a lot of numeric work, and does come across NANs, and still doesn't like them one bit.)
-- Steven
- Previous message: [Python-Dev] PyObject_RichCompareBool identity shortcut
- Next message: [Python-Dev] PyObject_RichCompareBool identity shortcut
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]