Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add benchmark comparing join of gen expression vs join of list comp #4

Merged
merged 1 commit into from
May 25, 2022

Conversation

pamelafox
Copy link
Contributor

Typically generator expressions are supposed to be more performance, but apparently str.join converts an iterable arg to a list anyway, if its not yet, so generator expressions add an overhead for conversion.

https://stackoverflow.com/questions/37782066/list-vs-generator-comprehension-speed-with-join-function
Current source code:
https://github.com/python/cpython/blob/main/Objects/unicodeobject.c#L9375

In my scalene tests, performance is better for the list comprehension version. This benchmark should show that as well, though I'm not sure if I've formatted it correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants