AlenkaF commented on code in PR #40761:
URL: https://github.com/apache/arrow/pull/40761#discussion_r1537398776


##########
python/pyarrow/types.py:
##########
@@ -64,17 +82,17 @@ def is_boolean(t):
 
 @doc(is_null, datatype="any integer")
 def is_integer(t):
-    return t.id in _INTEGER_TYPES
+    return is_integer_type(t)
 
 
 @doc(is_null, datatype="signed integer")
 def is_signed_integer(t):
-    return t.id in _SIGNED_INTEGER_TYPES
+    return is_signed_integer_type(t)
 
 
 @doc(is_null, datatype="unsigned integer")
 def is_unsigned_integer(t):
-    return t.id in _UNSIGNED_INTEGER_TYPES
+    return is_unsigned_integer_type(t)
 
 
 @doc(is_null, datatype="int8")

Review Comment:
   I would suggest checking for `bit_width(t)` together with 
`is_integer_type(t)`. Both are exposed in this PR.



##########
python/pyarrow/types.py:
##########
@@ -20,29 +20,47 @@
 
 from pyarrow.lib import (is_boolean_value,  # noqa
                          is_integer_value,
-                         is_float_value)
+                         is_float_value,
+                         is_integer_type,
+                         is_signed_integer_type,
+                         is_unsigned_integer_type,
+                         is_floating_type,
+                         is_numeric_type,
+                         is_decimal_type,
+                         is_run_end_type_py,
+                         is_primitive_type,
+                         is_base_binary_like_type,
+                         is_binary_like_type,
+                         is_large_binary_like_type,
+                         is_binary_type,
+                         is_string_type,
+                         is_temporal_type,
+                         is_time_type,
+                         is_date_type,
+                         is_interval_type,
+                         is_dictionary_type,
+                         is_fixed_size_binary_type,
+                         is_fixed_width_type,
+                         is_var_length_list_type,
+                         is_list_type,
+                         is_list_like_type,
+                         is_var_length_list_like_type,
+                         is_list_view_type,
+                         is_nested_type,
+                         is_union_type,
+                         is_bit_width_type,
+                         is_offset_bit_width_type)
 
 import pyarrow.lib as lib
 from pyarrow.util import doc
 
 
-_SIGNED_INTEGER_TYPES = {lib.Type_INT8, lib.Type_INT16, lib.Type_INT32,
-                         lib.Type_INT64}
-_UNSIGNED_INTEGER_TYPES = {lib.Type_UINT8, lib.Type_UINT16, lib.Type_UINT32,
-                           lib.Type_UINT64}
-_INTEGER_TYPES = _SIGNED_INTEGER_TYPES | _UNSIGNED_INTEGER_TYPES
-_FLOATING_TYPES = {lib.Type_HALF_FLOAT, lib.Type_FLOAT, lib.Type_DOUBLE}
-_DECIMAL_TYPES = {lib.Type_DECIMAL128, lib.Type_DECIMAL256}
 _DATE_TYPES = {lib.Type_DATE32, lib.Type_DATE64}
 _TIME_TYPES = {lib.Type_TIME32, lib.Type_TIME64}
 _INTERVAL_TYPES = {lib.Type_INTERVAL_MONTH_DAY_NANO}
 _TEMPORAL_TYPES = ({lib.Type_TIMESTAMP,

Review Comment:
   It is a bit annoying they are being handled differently.
   We can use multiple C++ functions to get what is expected in Python, for 
example:
   
   ```python
   is_temporal_type(t) and is_interval_type(t) and is_duration(t)   # assuming 
is_duration_type can be referenced from C++?
   ```
   but ideally the definitions would match between C++ and Python.
   



-- 
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]

Reply via email to