Last active
January 17, 2018 08:30
-
-
Save sidazhou/c26b9cf98cbbaf13ecfda8baba56c28c to your computer and use it in GitHub Desktop.
pickling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pickle | |
class Dummy: | |
def __init__(self,num): | |
self.num = num | |
dummy = Dummy(666) | |
print(dummy) # this is object pointer, not the object | |
stored = pickle.dumps({'my_object': dummy}) | |
restored = pickle.loads(stored) | |
# this shows pickle stores the pointed object, instead of just the object pointer | |
print(restored) | |
print(restored['my_object'].num) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment