MCPcopy Create free account
hub / github.com/python/cpython / PickleCopier

Class PickleCopier

Lib/test/test_descr.py:5746–5761  ·  view source on GitHub ↗

This class copies object using pickle.

Source from the content-addressed store, hash-verified

5744 """Utility method to generate the many possible pickle configurations.
5745 """
5746 class PickleCopier:
5747 "This class copies object using pickle."
5748 def __init__(self, proto, dumps, loads):
5749 self.proto = proto
5750 self.dumps = dumps
5751 self.loads = loads
5752 def copy(self, obj):
5753 return self.loads(self.dumps(obj, self.proto))
5754 def __repr__(self):
5755 # We try to be as descriptive as possible here since this is
5756 # the string which we will allow us to tell the pickle
5757 # configuration we are using during debugging.
5758 return ("PickleCopier(proto={}, dumps={}.{}, loads={}.{})"
5759 .format(self.proto,
5760 self.dumps.__module__, self.dumps.__qualname__,
5761 self.loads.__module__, self.loads.__qualname__))
5762 return (PickleCopier(*args) for args in
5763 itertools.product(range(pickle.HIGHEST_PROTOCOL + 1),
5764 {pickle.dumps, pickle._dumps},

Callers 1

Calls

no outgoing calls

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…