thisisnic commented on code in PR #45818: URL: https://github.com/apache/arrow/pull/45818#discussion_r2102181686
########## python/pyarrow/scalar.pxi: ########## @@ -238,6 +241,9 @@ cdef class UInt8Scalar(Scalar): cdef CUInt8Scalar* sp = <CUInt8Scalar*> self.wrapped.get() return sp.value if sp.is_valid else None + def __int__(self): + return self.as_py() Review Comment: I'm a bit unsure how to approach this for floats. I was going to put a cast in the `__int__` method and cast halffloats to int32 and floats to int64 (to account for the higher possible max value). But I'm not sure how to do this for doubles. I considered just casting to int64 and erroring on overflow, but if I set options to allow truncation, it then disables the option to error on integer overflow. Is there another way, or are we best perhaps not defining the `__int__` method for floats, and letting people do the casts manually themselves if they want to do this? -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org