New submission from Michael Selik: Minor, but it looks like someone decided to use a defaultdict but forgot to remove the checks for whether a key exists.
Creating a defaultdict(list): https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/lib2to3/btm_matcher.py#L100 Checking for the key, then initializing an empty list: https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/lib2to3/btm_matcher.py#L120 Again: https://github.com/python/cpython/blob/6f0eb93183519024cb360162bdd81b9faec97ba6/Lib/lib2to3/btm_matcher.py#L137 Because the ``results`` is getting returned, perhaps it'd be better to use a regular dict and dict.setdefault instead of a defaultdict. ---------- components: 2to3 (2.x to 3.x conversion tool) messages: 290955 nosy: selik priority: normal severity: normal status: open title: unnecessary LBYL for key contained in defaultdict, lib2to3/btm_matcher _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29957> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com