lets assume the following simple Object:
class Mock:
def __init__(self, name, age):
self.name = name
self.age = age
then I
You might want to pre-index them -
from collections import defaultdict
class Mock(object):
age_index = defaultdict(list)
def __init__(self, name, age):
self.name = name
self.age = age
Mock.age_index[age].append(self)
@classmethod
def find_by_age(cls, age):
return Mock.age_index[age]
Edit: a picture is worth a thousand words:
X axis is number of Mocks in myList, Y axis is runtime in seconds.