You could slightly modify the code from here to add a large_keys
attribute. Now, whenever one of those large epochs gets added, the dict will keep track of them. When you want to iterate over them, you can simply iterate over that attribute.
class MyUpdateDict(dict):
def __init__(self, *args, **kwargs):
self.large_keys = []
self.update(*args, **kwargs)
def __setitem__(self, key, value):
# optional processing here
if int(key)>1363033000:
self.large_keys.append((key,value))
super(MyUpdateDict, self).__setitem__(key, value)
def update(self, *args, **kwargs):
if args:
if len(args) > 1:
raise TypeError("update expected at most 1 arguments, got %d" % len(args))
other = dict(args[0])
for key in other:
self[key] = other[key]
for key in kwargs:
self[key] = kwargs[key]
def setdefault(self, key, value=None):
if key not in self:
self[key] = value
return self[key]
This might be overly simplistic, because the large value is hard-coded, but you can modify to make it a bit more appropriate.