Bug #24960
Change "in list(mydict.keys())" to "in mydict" when possible
0%
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 4 months ago
- Assignee set to Marco Mambelli
#2 Updated by Marco Mambelli 4 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 4 months ago
- Assignee changed from Marco Mambelli to Thomas Hein
#4 Updated by Marco Mambelli 4 months ago
- Target version changed from 2122 to v3_9_1