def savefile(obj, filepath, compress=True):
try:<EOL><INDENT>import cPickle as pickle<EOL><DEDENT>except Exception:<EOL><INDENT>import pickle<EOL><DEDENT>import joblib<EOL>tmpfile = filepath + '<STR_LIT>'<EOL>mkdir_if_not(tmpfile)<EOL>if compress:<EOL><INDENT>joblib.dump(obj, tmpfile, compress=<NUM_LIT:3>, cache_size=<NUM_LIT:100>, protocol=pickle.HIGHEST_PROTOCOL)<EOL><DEDENT>else:<EOL><INDENT>joblib.dump(obj, tmpfile, compress=<NUM_LIT:0>)<EOL><DEDENT>os.rename(tmpfile, filepath)<EOL>return obj<EOL>
파일 있으면 덮어씀
:param obj:
:param str filepath:
:param compress:
:return: