Apr-21-2021, 12:09 PM
Are you passing a list of dictionary names because you think this has less overhead than passing a list of dictionaries? That is incorrect. A python dictionary variable is going to be 4 or 8 bytes. A python string variable is going to be 4 or 8 bytes. A list of dictionary names will be the same size as a list of dictionaries.
There are several posts in this forum asking how you can programmatically create new variable names. The poster assumes that since the program manipulates multiple variables that each of the variables must have a name. They are nearly always incorrect. Variable names are mnemonics for writing and reading code. Python does not care what your variables are named. "spam", "eggs", dictlist[0] and dictionaries["eggs"] can all reference a dictionary.
If you know there will only be a "spam" dictionary then it is good to use a variable named "spam". If you have two dictionaries it may make sense to think of using a collection. If you have many dictionaries and the number is variable, a collection is definitely the way to go.
There are several posts in this forum asking how you can programmatically create new variable names. The poster assumes that since the program manipulates multiple variables that each of the variables must have a name. They are nearly always incorrect. Variable names are mnemonics for writing and reading code. Python does not care what your variables are named. "spam", "eggs", dictlist[0] and dictionaries["eggs"] can all reference a dictionary.
If you know there will only be a "spam" dictionary then it is good to use a variable named "spam". If you have two dictionaries it may make sense to think of using a collection. If you have many dictionaries and the number is variable, a collection is definitely the way to go.