Say I have a list of objects called agents
with 100,000 objects.
I have a second list called agents_per_step
which refers to 39,393 objects in agents
.
Say I need to access the agents in the reference list. What is the fastest way to access these objects?
I ran three tests:
- Loop through a list directly containing
agent
objects - Loop through a list of indices referring to
agents
objects on alist
- Loop through a list of indices referring to
agents
objects on adict
I present the results below:
Turns out the winner is Method 1, looping through a list directly containing agent
objects. Correct me if you can think of a way to make this run even faster!