MCPcopy Create free account
hub / github.com/apache/arrow / VisitIterable

Function VisitIterable

python/pyarrow/src/arrow/python/iterators.h:178–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

176// keep_going). If keep_going is set to false, the iteration terminates
177template <class VisitorFunc>
178inline Status VisitIterable(PyObject* obj, VisitorFunc&& func) {
179 if (PySequence_Check(obj)) {
180 // Numpy arrays fall here as well
181 return VisitSequence(obj, /*offset=*/0, std::forward<VisitorFunc>(func));
182 }
183 // Fall back on the iterator protocol
184 OwnedRef iter_ref(PyObject_GetIter(obj));
185 PyObject* iter = iter_ref.obj();
186 RETURN_IF_PYERROR();
187 PyObject* value;
188
189 bool keep_going = true;
190 while (keep_going && (value = PyIter_Next(iter))) {
191 OwnedRef value_ref(value);
192 RETURN_NOT_OK(func(value_ref.obj(), &keep_going));
193 }
194 RETURN_IF_PYERROR(); // __next__() might have raised
195 return Status::OK();
196}
197
198} // namespace internal
199} // namespace py

Callers 1

VisitIterableMethod · 0.85

Calls 3

VisitSequenceFunction · 0.85
funcFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected