I am trying to create a small server-type application and ask a question about organizing data using dicts. Right now I am grouping data using a connection socket (mainly to check where it comes from and to send data). Something like this: connected[socket] = account_data. In principle, each connected person will have account information. Since some fields will be used to compare and verify information, such as account ID, I want to speed up work with another dict.
For example: to find the account ID with the above method, I would have to use the for loop to go through all the available connections in the connection, look at the account ID in account_data for each, and then compare it. This seems to be a slow way to do this. If I could create a dict and use the accountID as the key, I think this might speed things up a bit. The problem is that I plan to use 3 different dicts, all ordered in different ways. Some data can change frequently, and it seems more hassle to update each individual dict after changing the information; is there anyway to tie them together?
Maybe an easier way to explain what I ask: You have Dict A, Dict B, Dict C and Data. Dict A, B and C contain the same data. I want this to happen if something changes in Data, the data in Dict A, B and C all change. Of course, I can always do dict A = data, dict B = data, etc., but after a while they will be repeated in the code. I know that data is set after creating a dict, so I'm not sure if there is a solution for this. I'm just looking for advice on the best way to organize data in this situation.
source
share