Option 1 behaves closer to Python's setdefault, since it only writes when the key is actually missing. Option 2 calls set_value on every read, which is harmless, but anyone reading a call site later will assume something changed
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments