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

Performance enhancement by using string concat vs list joins. #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

justecorruptio
Copy link

Theoretically, appending to lists and the joining and the end should be faster; but empirically, we've found that just doing string concats is actually faster anywhere from 2x to 5x depending on the template.

@wbond
Copy link
Owner

wbond commented Aug 15, 2015

Instead of repeatedly concating strings, could you try using cStringIO/BytesIO (Python 2/3)?

Additionally, from looking through the change, it seems you've mixed this performance tweak in with some other changes. I'd rather approach each change separately so we can evaluate what affects they may have. Specifically the change in order to pick() and __call__ to callable.

@justecorruptio
Copy link
Author

I can pull the other changes not related to concats to a separate PR, although they're both changes that affect performance.

cStringIO is still slower :-/

@justecorruptio
Copy link
Author

OK, I've reverted the the call -> callable and pick() order changes for now.

@adamantike
Copy link

@wbond @isaacdd would you consider merging this if conflicts are fixed?

michaelmanganiello-eb pushed a commit to eventbrite/pybars3 that referenced this pull request Oct 22, 2019
Port of Jay Chan's fix [0] [1], applied to the `0.9.1` tag. We have been
using this fix for years, without any issues.

[0] justecorruptio@a8d4027
[1] wbond#21
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.

3 participants