'If the dict grows a lot, I want to trim it. Basically, if it grows to a
length of more than 2000 keys, I\'ll trim it to 1000 keys.'

def _trim_data(self, data):

    if (len(data) < 2000):
        return data
    items = data.items()
    items.sort(sort_func)
    items = items[:1000]
    new_data = {}
    for (key, value) in items:
        new_data[key] = value
    return new_data
