#!/usr/local/bin/python2 import cPickle as pickle import copy class C(object): def __init__(self, a): self.a = a c = C([3]) c4 = c z = pickle.dumps(c) c2 = pickle.loads(z) c3 = pickle.loads(z) print id(c), id(c2), id(c3), id(c4) c2.a.append(2) c.a.append(4) print c.a, c2.a, c3.a, c4.a c = C([3]) c4 = c c2 = copy.deepcopy(c) c3 = copy.deepcopy(c) print id(c), id(c2), id(c3), id(c4) c2.a.append(2) c.a.append(4) print c.a, c2.a, c3.a, c4.a