pybars3 icon indicating copy to clipboard operation
pybars3 copied to clipboard

Performance enhancement by using string concat vs list joins.

Open justecorruptio opened this issue 10 years ago • 4 comments

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.

justecorruptio avatar Aug 12 '15 04:08 justecorruptio

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.

wbond avatar Aug 15 '15 19:08 wbond

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 avatar Aug 17 '15 23:08 justecorruptio

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

justecorruptio avatar Sep 17 '15 22:09 justecorruptio

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

adamantike avatar Jul 05 '19 01:07 adamantike