randolf-scholz commented on issue #34987: URL: https://github.com/apache/arrow/issues/34987#issuecomment-3607375108
> I think __bool__ should return False if the given scalar is null. @pitrou Do you not think my comment https://github.com/apache/arrow/issues/34987#issuecomment-3552310153 and https://github.com/apache/arrow/pull/34993#issuecomment-1685415286 here my a good case why this behavior may be undesirable? In essence, it kind of boils down to this: In python `None` and `bool` are different types. While it is true that `None` can be cast to a boolean, giving `False`, `None` typically doesn't fall out of other arithmetic because python's builtin types are not nullable. So when one does something like `if value > reference` with builtin types, there is no possibility to accidentally coerce a `None` to `False`. However, with `arrow`, the standard scalars are nullable, and the usual interpretation is that `Null` ⇿ missing value. So if I were to do `if value > reference:` with pyarrow types, there are actually 3 options: `True`, `False` or `Null`, i.e. we have a 3-valued logic. In my estimation, one would usually want to handle the `Null` case separately, same as in python, even the comparison `value > reference` would be illegal if `value` were `float | None` instead of just `float`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
