Last active
June 9, 2018 00:13
-
-
Save shao-wang-me/4d06d193c0307a62dec06ed6df4913ff to your computer and use it in GitHub Desktop.
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 numpy as np | |
import json | |
import pickle | |
a = np.random.random(1000000) | |
# a = np.zeros(1000000) | |
print(a) | |
a.dump('np_dump') | |
with open('pickle_dump', 'wb') as f: | |
pickle.dump(a, f, protocol=pickle.HIGHEST_PROTOCOL, fix_imports=False) | |
np.save('np_save_pickle', a, allow_pickle=True, fix_imports=False) | |
np.save('np_save_no_pickle', a, allow_pickle=False, fix_imports=False) | |
np.savez('np_savez', a) | |
np.savez_compressed('np_savez_compressed', a) | |
np.savetxt('np_savetxt', a) | |
np.savetxt('np_savetxt.gz', a) | |
b = a.tolist() | |
with open('pickle_dump_tolist', 'wb') as f: | |
pickle.dump(b, f, protocol=pickle.HIGHEST_PROTOCOL, fix_imports=False) | |
with open('json_dump', 'w') as f: | |
json.dump(b, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment