External Publication
Visit Post

Is interning as a general primitive something that should be in the standard library?

Rust Internals [Unofficial] May 2, 2026
Source

Andyou007:

Every system that accepts input from humans operates on two concepts that are currently absent from core:

  1. A way to store and retrieve values by a stable integer identity (1-based ordinal, where 0 is the null sentinel โ€” the only meaningful null for a computer)
  2. A way to recognize that two inputs are the same value โ€” interning

Apart from everything else, this is a strong claim, requiring equally strong evidence, which you haven't provided at all.

I would personally argue that interning (and, more generally, memoization) are only sometimes useful. They can't be used, for instance, when you need to process an unbounded stream of data using a constant amount of space, which is the most common case in my experience for data crunching tasks (and yes, that data stream might be coming from a human).

It's also very easy to build an interner on top of things that the standard library already gives you, e.g. HashMap<String, u32>, which means the benefit of adding an "official" interner to the standard library would be quite limited.

Discussion in the ATmosphere

Loading comments...