Skip to content

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 justecorruptio force-pushed the jay-performance-string-concat branch from ac6b304 to 949c1ed Compare September 17, 2015 22:25
@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