-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avoid unnecessary computing with pickling computed enf-samples
- Loading branch information
Showing
2 changed files
with
43 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import bz2 | ||
import pickle | ||
import _pickle as cPickle | ||
import sys | ||
|
||
|
||
# Pickle a file and then compress it into a file with extension | ||
def compress_pickle(filename, data): | ||
sys.stderr.write("loading pickle %s..." % filename) | ||
with bz2.BZ2File(filename, 'w') as f: | ||
cPickle.dump(data, f) | ||
|
||
# Load any compressed pickle file | ||
def decompress_pickle(filename): | ||
sys.stderr.write("saving pickle %s..." % filename) | ||
data = bz2.BZ2File(filename, 'rb') | ||
data = cPickle.load(data) | ||
return data | ||
|
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