Move away from __dict__ style save/load
Incompatible with previous versions, but necessary given the move to __slots__. Also use pickle.HIGHEST_PROTOCOL
This commit is contained in:
parent
28084dfe45
commit
503a77925e
1 changed files with 2 additions and 4 deletions
|
|
@ -511,10 +511,8 @@ class Pattern:
|
||||||
:return: Loaded Pattern
|
:return: Loaded Pattern
|
||||||
"""
|
"""
|
||||||
with open(filename, 'rb') as f:
|
with open(filename, 'rb') as f:
|
||||||
tmp_dict = pickle.load(f)
|
pattern = pickle.load(f)
|
||||||
|
|
||||||
pattern = Pattern()
|
|
||||||
pattern.__dict__.update(tmp_dict)
|
|
||||||
return pattern
|
return pattern
|
||||||
|
|
||||||
def save(self, filename: str) -> 'Pattern':
|
def save(self, filename: str) -> 'Pattern':
|
||||||
|
|
@ -525,7 +523,7 @@ class Pattern:
|
||||||
:return: self
|
:return: self
|
||||||
"""
|
"""
|
||||||
with open(filename, 'wb') as f:
|
with open(filename, 'wb') as f:
|
||||||
pickle.dump(self.__dict__, f, protocol=2)
|
pickle.dump(self, f, protocol=pickle.HIGHEST_PROTOCOL)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def visualize(self,
|
def visualize(self,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue