# this is just a suitably modified memoize() method so you can see the # same output I see... Substitute as appropriate in pickle.py. def memoize(self, obj): """Store an object in the memo.""" # The Pickler memo is a dictionary mapping object ids to 2-tuples # that contain the Unpickler memo key and the object being memoized. # The memo key is written to the pickle and will become # the key in the Unpickler's memo. The object is stored in the # Pickler memo so that transient objects are kept alive during # pickling. # The use of the Unpickler memo length as the memo key is just a # convention. The only requirement is that the memo values be unique. # But there appears no advantage to any other scheme, and this # scheme allows the Unpickler memo to be implemented as a plain (but # growable) array, indexed by memo key. if self.fast: return print >> sys.stderr, (obj.__class__, hex(id(obj))), if isinstance(obj, (str, dict, tuple, list, int, float, type)): print >> sys.stderr, "<%s>" % (obj,), elif hasattr(obj, "func_name"): print >> sys.stderr, repr(obj.func_name), print >> sys.stderr assert id(obj) not in self.memo memo_len = len(self.memo) self.write(self.put(memo_len)) self.memo[id(obj)] = memo_len, obj print "memoized", hex(id(obj))