Implement `Array.__iter__`
See original GitHub issueThis came up recently in https://github.com/pandas-dev/pandas/issues/38645 and I took a greedy stab at implementing it in: https://github.com/dask/dask/pull/7888
I abandoned that PR because a bunch of tests failed and I feel like it’s at least a little surprising to have list(array) return a list of real values. It seems too easy to do by mistake.
For context, currently on main if you call list(array) you get an array of getitem calls with the same length as the 0th dimension of the array. It’s possible that is already the best solution. In which case we can probably close this.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
java - Default iterator implementation for array of Object (T[])?
Closest thing to a default implementation in the JDK: Arrays.asList(array).iterator(). Simple custom implementation:
Read more >Array.prototype[@@iterator]() - JavaScript - MDN Web Docs
The @@iterator method of an Array object implements the iterable protocol and allows arrays to be consumed by most syntaxes expecting ...
Read more >An example of implementing Iterable and Iterator in Java
Implementing an iterator over some collection, in this case an array. // * Implementing the Iterable interface, which enables your collection.
Read more >How to convert Java Array to Iterable? - Tutorialspoint
To make an array iterable either you need to convert it to a stream or as a list using the asList() or stream()...
Read more >How Does an Array Iterator Works in Java? - eduCBA
Java Array Iterator defined as iterating all the array elements by applying different looping logic on the array. Arrays are used to store...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hello, I’ve been following this with interest, and also agree that the “array of getitem calls with the same length as the 0th” is what I would expect to occur (i.e. not returning computed numpy arrays).
Thanks, David
On main you get