Skip to content

Commit

Permalink
when pickling variables and predicates remove unnecessary bits
Browse files Browse the repository at this point in the history
this dramatically reduces the size of the settings file
  • Loading branch information
fgregg committed Feb 4, 2022
1 parent 9ba44fa commit 0a2d785
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dedupe/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def __init__(self, threshold, field):
def __getstate__(self):
odict = self.__dict__.copy()
odict['index'] = None
odict['_cache'] = {}
if 'canopy' in odict:
odict['canopy'] = {}
return odict

def __setstate__(self, d):
Expand Down
6 changes: 6 additions & 0 deletions dedupe/variables/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ def __init__(self, definition):
else:
self.has_missing = False

def __getstate__(self):
odict = self.__dict__.copy()
odict['predicates'] = None

return odict


class DerivedType(Variable):
type = "Derived"
Expand Down

1 comment on commit 0a2d785

@az0
Copy link
Contributor

@az0 az0 commented on 0a2d785 Feb 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgregg
This helped. Thank you

Please sign in to comment.