Relative Content

Tag Archive for pythondata-structures

Efficient data structure for matching items in two lists of data -python

I have two lists where one list is filled with ID’s and the other list is filled with process names. Multiple process names can share an ID. I want to be able to create a data structure where I can use a specific ID and then return the list of processes associated with that ID. I also want to be able to use a specific process name and return the list of ID’s it’s connected with. I know I could create a dictionary for this but the list of ID’s will be very large and will continue to grow but the process names will be fairly short (fewer than 20 most likely) and will not grow as much. I’m not sure how efficient a dictionary will be in the long run. I want to be able to store the connections between the two lists locally on my computer so I can reload them into my program to add new connections for new ID’s.

Is there a way to make a dictonary of mapped values?

I have a segment of code that is dramatically slowing down an optimization procedure to the point where it is basically not useable. I have attached the segment here and am hoping there is some way where it does not need to ‘re-map’ for every tuple I have to give it per optimization step (which is 200 tuples). So each time this function is called it does the remapping. I am hoping to define the mapping once and per each step in the optimizer it only needs to pull the new values that the optimizer changed rather than redo the mapping with this complex scheme I have developed. I have also described the code below this snippet. Any help would be appreciated!