Hacker News new | ask | show | jobs
by emil-lp 192 days ago
The point is that freeze could work in constant time, whereas the copying takes linear time.

Another alternative mentioned was `move`, which would create a frozen version in constant time and clear the original dict.

1 comments

Freeze can't work in constant time if it builds a hash when the dict is frozen so that the dict can be used as a key.

If all it does is set a flag that prevents modifications, that's different.