Settings

Theme

Python proposal: add immutable (persistent) dictionaries

python.org

17 points by dikbrouwer 6 years ago · 6 comments

Reader

snrji 6 years ago

This is the kind of ad-hoc PEP proposal that could be completely avoidable if there was a generic modifier or initialization/declaration construction for declaring a variable as constant. So incredibly simple, so incredibly useful that it's hard to believe that it hasn't been accepted yet (it was proposed).

  • laurencerowe 6 years ago

    A const declaration only ensures that the variable always points to the same object, not that that object is immutable. For instance in JS:

    const foo = {};

    foo.bar = 1;

yen223 6 years ago

Something interesting to note is that Python’s ContextVar (introduced in Python 3.7) is a persistent dictionary.

https://www.python.org/dev/peps/pep-0567/#implementation

lolc 6 years ago

Nice I like having persistent structures available. Then I don't have to safeguared against unintended modifications.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection