So, I would like to know what is the fastest way to iterate through a dictionary's value and compare it's value to another variable. I have a specific dictionary stucture which is really simple:
"data": [
{
"id": "xxxxxxxxxxxxx"
},
{
"id": "xxxxxxxxxxxxx"
},
{
"id": "xxxxxxxxxxxxx"
},
{
"id": "xxxxxxxxxxxxx"
},
{
"id": "xxxxxxxxxxxxx"
},
{
"id": "xxxxxxxxxxxxx"
}
]
I already loop through some_dict['data']
and then compare it's ['id']
value using this code:
for item in some_dict:
if item['id'] == some_value:
#do stuff
But with a large size dictionary, it takes a lot of time so I was curious about other ways to do what i wanted. I heard of set which are good for huge list iteration but is there anyway to use it from my dict structure?