viirya commented on code in PR #50327:
URL: https://github.com/apache/arrow/pull/50327#discussion_r3630954278


##########
python/pyarrow/array.pxi:
##########
@@ -1864,7 +1864,21 @@ cdef class Array(_PandasConvertible):
         lst : list
         """
         self._assert_cpu()
-        return [x.as_py(maps_as_pydicts=maps_as_pydicts) for x in self]
+        cdef int64_t i, n = self.length()
+        if maps_as_pydicts is not None:
+            # Converting maps to dicts has per-entry semantics (duplicate-key
+            # detection); use the Scalar-based conversion for exact behavior.
+            return [x.as_py(maps_as_pydicts=maps_as_pydicts) for x in self]

Review Comment:
   @rok Sounds good — filed GH-50604. For the record on current behavior: a 
top-level `to_pylist` override on a subclass still dispatches normally via 
Python method resolution; the bypass only concerns *nested* children, where the 
previous behavior was already inconsistent — list children went through 
`child.to_pylist()` (override honored) while struct/map children were converted 
via per-field Scalars (override ignored). `ExtensionScalar.as_py` / 
`__arrow_ext_scalar_class__` remains honored on all paths, before and after 
this PR.



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