I wonder whether Raymond Hettinger has an opinion on this PEP. A long time ago, he wrote: "freezing dicts is a can of worms and not especially useful".
https://mail.python.org/pipermail/python-dev/2006-February/0...
replies(8):
https://mail.python.org/pipermail/python-dev/2006-February/0...
Kotlin _kinda_ does this as well, but if you have a reference to an immutable map in Kotlin, you are still free to mutate the values (and even keys!) as much as you like.
If you in fact return e.g. an Rc::new(thing) or Arc::new(thing), that's forever (though of course you can unwrap the last reference!)
Might be worth noting that "dropped" in this context doesn't necessarily correspond to the reference going out of scope:
fn get_first(v: &Vec<i32>) -> &i32 {
&v[0]
}
fn main() {
let mut v = vec![0, 1, 2];
let first = get_first(&v);
print!("{}", first});
v.push(3); // Works!
// print!("{}", first); // Doesn't work
}