5 ms·
Because it was such a common problem, CPython 3 tries to detect such string concatenation and handle it like a list of strings concatenation internally. Have y
by BiteCode_dev 3y ago
Because it was such a common problem, CPython 3 tries to detect such string concatenation and handle it like a list of strings concatenation internally.
Have you measured that your code is significantly faster than the original one?
- ploum 3y agoI was not aware of that problem. The do_info is trivial anyway, so performance is not an issue there. But in ansicat, that might speed up significantly the HTML rendering (which is quite expensive with images transformed as ANSI strings by Chafa). So I would be curious to have some benchmark and would happily accept patches improving performances in ansicat.
- BiteCode_dev 3y agoIf html rendering is really a big bottleneck, a bytearray could be even faster, provided you accept the compromise of manipulating encoded strings. And a rope for even more perfs. But yes, benchmarks are very much necessary.
- ploum 3y agoI’ve learned quite quickly that you never do any performance job without profiling. Never! Even if the optimisation looks straightforward.