[Python-checkins] [python/cpython] 11fa3c: bpo-29957: change LBYL key lookup to dict.setdefau...

GitHub noreply at github.com
Sun Apr 2 02:02:32 EDT 2017


  Branch: refs/heads/master
  Home:   https://github.com/python/cpython
  Commit: 11fa3c7cd1b151e302d4eee0369cafbaf151c8fb
      https://github.com/python/cpython/commit/11fa3c7cd1b151e302d4eee0369cafbaf151c8fb
  Author: Michael Selik <mike at selik.org>
  Date:   2017-04-01 (Sat, 01 Apr 2017)

  Changed paths:
    M Lib/lib2to3/btm_matcher.py
    M Misc/ACKS

  Log Message:
  -----------
  bpo-29957: change LBYL key lookup to dict.setdefault (#938)

* change LBYL key lookup to dict.setdefault

The ``results`` was constructed as a defaultdict and we could simply
delete the check ``if key not in results``. However, I think it's safer
to use dict.setdefault as I'm not sure whether the caller expects a
regular dict or defaultdict.

* add name to the acknowledgements file

* use defaultdict to make the key-lookup cleaner




More information about the Python-checkins mailing list