https://stackoverflow.com/questions/1316887/what-is-the-most-efficient-string-concatenation-method-in-python
https://stackoverflow.com/questions/39622122/python-string-concatenation-in-for-loop-long-strings
It's interesting that, in python2.x
str += str2 is faster then "".join((str, str2))
in python3, the later is faster.
However, the memory usage hasn't been counted in above methods.
Guess?
I would say "".join would probably using less memory due to a hunch from c++ background,
still, profiling instead of guessing :-P
https://stackoverflow.com/questions/39622122/python-string-concatenation-in-for-loop-long-strings
It's interesting that, in python2.x
str += str2 is faster then "".join((str, str2))
in python3, the later is faster.
However, the memory usage hasn't been counted in above methods.
Guess?
I would say "".join would probably using less memory due to a hunch from c++ background,
still, profiling instead of guessing :-P
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.