Created
August 17, 2021 14:34
-
-
Save Tishka17/0b941ab1e6ca6dda396302b3cd8fddb9 to your computer and use it in GitHub Desktop.
Clooudpickle experiment
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
class Helper: | |
def do(self): | |
print(3) |
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 cloudpickle as pickle | |
with open("x.pkl", "rb") as f: | |
pickle.load(f).do() |
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 cloudpickle as pickle | |
from numpy import ndarray | |
from helper import Helper | |
class A: | |
def __init__(self, value): | |
self.value = value | |
self.array = ndarray([1, 2, 3]) | |
def do(self): | |
print(self.value, self.array) | |
Helper().do() | |
def save(value): | |
a = A(value) | |
with open("x.pkl", "wb") as f: | |
return pickle.dump(a, f) | |
x = save(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment