amol- commented on a change in pull request #11076:
URL: https://github.com/apache/arrow/pull/11076#discussion_r707274156
##########
File path: cpp/src/arrow/python/inference.cc
##########
@@ -354,12 +354,17 @@ class TypeInferrer {
*keep_going = make_unions_;
} else if (PyArray_CheckAnyScalarExact(obj)) {
RETURN_NOT_OK(VisitDType(PyArray_DescrFromScalar(obj), keep_going));
- } else if (PyList_Check(obj)) {
- RETURN_NOT_OK(VisitList(obj, keep_going));
+ } else if (PySet_Check(obj) || (Py_TYPE(obj) == &PyDictValues_Type)) {
+ RETURN_NOT_OK(VisitSet(obj, keep_going));
} else if (PyArray_Check(obj)) {
RETURN_NOT_OK(VisitNdarray(obj, keep_going));
} else if (PyDict_Check(obj)) {
RETURN_NOT_OK(VisitDict(obj));
+ } else if (PySequence_Check(obj)) {
+ // Deals with generic sequences. Including list and tuple.
Review comment:
The `PySequence_Check` is necessary to ensure we support
`collections.deque` which was supported at top level (`array(deque)`) but not
at nested levels `array([deque])`. Using `PySequence` here adds support for
deques too.
I switched to checking explicitly the `deque` type instead of using
`PySequence_Check`, so now the check should be more explicit.
--
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]