return value

def __setitem__(self, key, value):
    i, k = self.lookup(key)
if k == key:
    self.store[i] = key, value
else:
    self.store.insert(i, (key, value))

def lookup(self, key):
    i = bisect.bisect(self.store, (key, self.empty))
if 0 <= i < len(self.store):
    return i, self.store[i][0]
return i, None
if __name__ == '__main__':
    s = mystore(set)
s['a'] = set(['1'])
print(s.store)
s['b']
print(s.store)
s['a'] = set(['2'])
print(s.store)
Python defaultdict for large data sets