Opened 3 years ago

Closed 3 years ago

#28249 closed Cleanup/optimization (fixed)

Remove unnecessary dict.keys() calls

Reported by: Jon Dufresne Owned by: nobody
Component: Uncategorized Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


iter(dict) is equivalent to iter(dict.keys()). Can simply act on the dictionary. Provides simpler, more concise syntax and avoids the extra function call in Django.

Inspired by Lennart Regebro's PyCon 2017 presentation "Prehistoric Patterns in Python". Available at:

Change History (2)

comment:1 Changed 3 years ago by Jon Dufresne

Has patch: set

comment:2 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: newclosed

In 21046e7:

Fixed #28249 -- Removed unnecessary dict.keys() calls.

iter(dict) is equivalent to iter(dict.keys()).

Note: See TracTickets for help on using tickets.
Back to Top