#!/usr/local/bin/python2 from collections import OrderedDict class C(object): name = 0 def __init__(self, v): self.name = v l = [C(), C(1), C(2), C(3), C(4), C(5), C(6), C(7), C(8), C(9)] for i in xrange(20000): m = {} n = [] n_append = n.append c = [] c_append = c.append for j in l: if j.name not in m: m[j.name] = j n_append(j.name) c_append(j) print m, n, c