Skip to content

iterations over awkward arrays #2392

Answered by jpivarski
grst asked this question in Q&A
Discussion options

You must be logged in to vote

You are right: imperative iteration over Awkward Arrays is considerably slower than iteration over Python builtin types, which is itself considerably slower than a vectorized computation. ("Considerably slower" means orders of magnitude, somewhere between 10× and 1000×.)

We have specialized, streamlined paths for simple ak.Array.__iter__ to make iteration as fast as possible, but it's a function-call stack several deep, terminating on Content._getitem_at, and that can't compete with the short path that Python builtins take to PyIter_Next and PyList_GetItem.

BEGIN details:

ak.Array.__iter__ has a specialized path for NumpyArray (here), in the hope that np.ndarray.__iter__ is a fast impleme…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by grst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants