>>> class A(object):
... def __init__(self, foo):
... self.f = {}
... for f in foo:
... self.f[f] = f
...
>>> class B(object):
... def __init__(self, foo):
... self.f = self_f = {}
... for f in foo:
... self_f[f] = f
...
>>> timeit.repeat('A(xrange(100))', 'from __main__ import A, B')
[10.20199990272522, 10.19700002670288, 10.188000202178955]
>>> timeit.repeat('B(xrange(100))', 'from __main__ import A, B')
[6.770999908447266, 6.759999990463257, 6.771000146865845]
(see full text)