bpo-29957: change LBYL key lookup to dict.setdefault#938
bpo-29957: change LBYL key lookup to dict.setdefault#938benjaminp merged 3 commits intopython:masterfrom
Conversation
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.
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
|
Why switch to |
|
The caller may expect that looking up a missing key will raise I don't know enough about the context here for how the |
|
I switched it back to |
The
resultswas constructed as a defaultdict and we could simplydelete the check
if key not in results. However, I think it's saferto use dict.setdefault as I'm not sure whether the caller expects a
regular dict or defaultdict.