This is an automated email from the ASF dual-hosted git repository.
paleolimbot pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-nanoarrow.git
The following commit(s) were added to refs/heads/main by this push:
new e322561 refactor(python): Cleaner strategy for `__iter__()` on an
`ArrowArrayStream` (#263)
e322561 is described below
commit e3225614ea65f4f36a8974574e8c0681df5fc00d
Author: Dewey Dunnington <[email protected]>
AuthorDate: Fri Jul 21 18:02:45 2023 -0300
refactor(python): Cleaner strategy for `__iter__()` on an
`ArrowArrayStream` (#263)
After
https://github.com/apache/arrow-nanoarrow/pull/262#discussion_r1269088588
.
---
python/src/nanoarrow/_lib.pyx | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/python/src/nanoarrow/_lib.pyx b/python/src/nanoarrow/_lib.pyx
index 84582b2..906eecf 100644
--- a/python/src/nanoarrow/_lib.pyx
+++ b/python/src/nanoarrow/_lib.pyx
@@ -894,11 +894,10 @@ cdef class ArrayStream:
return array
def __iter__(self):
- try:
- while True:
- yield self.get_next()
- except StopIteration:
- return
+ return self
+
+ def __next__(self):
+ return self.get_next()
@staticmethod
def allocate():