Every line of 'pickle dump dictionary' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
55 def pickle_dict(items): 56 '''Returns a new dictionary where values which aren't instances of 57 basestring are pickled. Also, a new key '_pickled' contains a comma 58 separated list of keys corresponding to the pickled values. 59 ''' 60 ret = {} 61 pickled_keys = [] 62 for key, val in items.items(): 63 if isinstance(val, basestring): 64 ret[key] = val 65 else: 66 pickled_keys.append(key) 67 ret[key] = pickle.dumps(val) 68 if pickled_keys: 69 ret['_pickled'] = ','.join(pickled_keys) 70 return ret
114 def load_dump(pickle_file): 115 with open(pickle_file, 'rb') as f: 116 data = pickle.load(f, encoding='bytes') 117 return data
298 def dump_dict(self, obj): 299 raise NotImplementedError
36 def savepickle(dct): 37 """ Save settings dict to the pickle file """ 38 with open('h5config.pkl','wb') as f: 39 pickle.dump(dct, f, protocol=0)
685 @classmethod 686 def dump(cls, obj, file_obj): 687 """Serialize object ``obj`` to open pickle file. 688 689 .. versionadded:: 1.8 690 691 :param obj: Python object to serialize 692 :type obj: Python object 693 :param file_obj: file handle 694 :type file_obj: ``file`` object 695 696 """ 697 698 return pickle.dump(obj, file_obj, protocol=-1)
5 def dump(obj, file_name): 6 with open(file_name, "wb") as f: 7 pickle.dump(obj, f)