Quick Recap
- As mentioned in one of the previous chapters, classes can implement the
+=
and+
operators differently. For concatenating more than two strings,+=
is faster. - To make giant strings iteratively, it is better to use format strings. If you have all the strings already available in an iterable, use the
join()
method. - Python implements some optimization for dictionary with string-only-keys, which make lookups faster (due to a faster string comparison method used for strings). This effect only stays until the dictionary is not polluted by non-
str
keys.
Get hands-on with 1400+ tech skills courses.