dict = {} ## pdg_index and unique id for w in pdg_node.workItems: dict[w.index] = w.id
I'm using this code to reconstruct an ordered dictionary of workitems of a pdg_node and their corresponding unique ID.
Problem: I just need to know a single specific unique ID, from a workitem index of a pdg.node. I don't want to iterate over all the workitems to reconstruct a dictionary.
Naively, I thought I could just access a workitem like this:
pdg_node.workItems[3]
Indeed the following code produce a unordered list of workitems, and an ordered dictionary of workitems. Might be a python thing? I didn't know that dictionaries get auto-sorted. My question remain, anyway..
wlist = [] dict = {} for w in pdg_node.workItems: wlist.append(w.index) for w in pdg_node.workItems: dict[w.index] = w.id