TLDR: How Python Uses String Interning to Keep Runtime Efficient
Date: 2020-12-20 Source: https://arpitbhayani.me/blogs/string-interning-python
Overview
Explore Python's string interning - a compiler optimization for performance. Learn how CPython uses it to boost speed and reduce memory use. Every programming language aims to be performant in its niche and achieving superior performance requires a bunch of compiler and interpreter level optimizations.
Key Points
- Every programming language aims to be performant in its niche and achieving superior performance requires a bunch of compiler and interpreter level optimizations.
- Why should Strings be interned?: String Interning speeds up string comparisons.
- Internals of String Interning: In CPython, the String references are stored, accessed, and managed using a Python dictionary named interned.
- String Interning in Action: Now that we understand the internals of String Interning and Cleanup, we find out what all Strings are interned in Python.