Project

General

Profile

Bug #24960

Change "in list(mydict.keys())" to "in mydict" when possible

Added by Marco Mambelli 7 months ago. Updated about 1 month ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
09/12/2020
Due date:
% Done:

0%

Estimated time:
First Occurred:
Occurs In:
Stakeholders:
Duration:

Description

If the keys of the dictionary are not changing (no insertions or deletions) it is possible to iterate on the keys instead of creating a list and iterating on it. This is more efficient. The logic is the same.

The list creation is necessary if the keys of the dictionary may change.

The construct results form the automatic conversion that uses it all the times to avoid problems when it is needed

History

#1 Updated by Marco Mambelli 7 months ago

  • Assignee set to Marco Mambelli

#2 Updated by Marco Mambelli 7 months ago

Changes in v39/24960
Using "grep -R list * | grep -v ^doc | grep -v ^Binary | grep keys" to find possible occurences.
Started replacing them from the top, first commit:
creation/lib/cWDictFile.py creation/lib/cWParams.py creation/lib/cgWDictFile.py creation/lib/cgWParamDict.py creation/lib/cgWParams.py creation/lib/cvWParamDict.py creation/lib/cvWParams.py creation/lib/xmlConfig.py factory/glideFactoryMonitoring.py

Many more to do in the remaining files (factory, frontend, install/services, lib, tools, unittests).

#3 Updated by Marco Mambelli 7 months ago

  • Assignee changed from Marco Mambelli to Thomas Hein

#4 Updated by Marco Mambelli 7 months ago

  • Target version changed from 2122 to v3_9_1

#5 Updated by Marco Mambelli about 2 months ago

  • Assignee deleted (Thomas Hein)

#6 Updated by Marco Mambelli about 1 month ago

  • Target version changed from v3_9_1 to v3_9_2

Also available in: Atom PDF