X Tutup
Skip to content

GH-98363: Presize the list for batched()#98419

Merged
rhettinger merged 6 commits intopython:mainfrom
rhettinger:better_batched
Oct 20, 2022
Merged

GH-98363: Presize the list for batched()#98419
rhettinger merged 6 commits intopython:mainfrom
rhettinger:better_batched

Conversation

@rhettinger
Copy link
Contributor

@rhettinger rhettinger commented Oct 18, 2022

Presizing the result lists saves space from list over-allocation and is faster than the PyList_Append() approach.

This is a short PR but it took a while to figure out that PyList_GetSlice() would make short work of the problem. Ideally, we need something like _PyTuple_Resize() to resize the list inplace using a realloc() and updating the allocated field.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Performance or resource usage skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup