Created
November 29, 2018 21:29
-
-
Save CosineP/38c88184358a3390e94845eee82b2be0 to your computer and use it in GitHub Desktop.
pickling memory works appropriately, keeping references in-tact
This file contains hidden or 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
# pickling memory works appropriately, keeping references in-tact | |
import pickle | |
heap = ['original'] | |
to_pickle = {'one': heap, 'two': heap} | |
s = pickle.dumps(to_pickle) | |
from_pickle = pickle.loads(s) | |
from_pickle['one'][0] = 'changed' | |
# outputs 'changed should be "changed"' | |
print(from_pickle['two'][0], 'should be "changed"') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment