Opened 7 years ago

Closed 7 years ago

#28249 closed Cleanup/optimization (fixed)

Remove unnecessary dict.keys() calls

Reported by: Jon Dufresne Owned by: nobody
Component: Uncategorized Version: dev
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

Description

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: https://www.youtube.com/watch?v=V5-JH23Vk0I

Change History (2)

comment:1 by Jon Dufresne, 7 years ago

Has patch: set

comment:2 by Tim Graham <timograham@…>, 7 years ago

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