Skip to content

Instantly share code, notes, and snippets.

"blockscope": k#81cecd3600c88780860105a15a874b3807600485581966271f6fdb51b6ac8af69a23fd1084bc8d4acefc7b6f8f48f8f80d281c48a9c35bdf0f2277c28adb99d8e4c38fdd445af8faf7b7e93e33333b15c0049278ad479b87197faf781b630305,
"CogentCrypto": k#85239eeb1da141cdd6a9e576ae96fb1d40683052e2de100a542e0893a9f40abda55a7e20a44842585f611476dd48391d10686d6394991d3ffd4c5fd547536126741a51947901955c8eee5be20a99d08735d5677ff253a88945376d4710abc300,
"InfStones": k#85ff6f9ae74be91a4a7b33f943639718ebef390e2427092e8e31923af5f8a32ef593d43848d0e47e03fb01ce898bfd660adb13c9c1a8e063cba27b84059b9b53dc32a67b5dd0acb1edcbb8ee0c65ec75ba294dd7abd259fc7ed6b7cc54f11644,
"Nodes.Guru": k#8606484188ce649c5706c4dd4444618e8e39075105499016e6b3ddf170ce1ba7799747b1ea4c229fcb4a82b02b97a9ef08b25a0e5ed392eceef89d8be42c3b62d855610d3ec8ffb12eda25f81007bea7380fff0cb4d2e539d7319a1be6d50e36,
"Coinbase Cloud": k#8b48ee49ff972a7d00f09dbca41ae6b87888c677e27dd033c2051cbacc16b28357e763cbd452b1f80beb3dc2177f93cd06d6d672a9eaeb49d20e8ac22964e400c154c32fd2c9bda78d869b6f0b132111eae

Comments on optimizations around string concatenation.

Note: The code links are to CPython 3.8.5, the most recent release when this was written.

I was recently asked about a performance optimization in CPython around using += and + for string objects. As some people may already know, if you use += or + a string, it can sometimes be just as fast as ''.join. The question was to explain when that optimization couldn't be performed.

We will be going through the following example scenarios: