[issue31240] Add lazy evaluation support for dict.setdefault()

Serhiy Storchaka report at bugs.python.org
Sun Aug 20 02:08:27 EDT 2017


Serhiy Storchaka added the comment:

The advantage of dict.setdefault() is its atomicity. With lazy evaluation of the value it can't be atomic anymore, and can be replaced with the following code:

    if key not in mydict:
        mydict[key] = value

I'm -1 for this change. It increases complexity (both semantical and implementational) of dict.setdefault() and doesn't have significant benefit.

----------
nosy: +rhettinger, serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue31240>
_______________________________________


More information about the Python-bugs-list mailing list