Equivalent to pickle.dumps except that the HoloViews option
        tree is saved appropriately.
494852
def dumps(cls, obj, protocol=0):
        
        cls.save_option_state = True
        val = pickle.dumps(obj, protocol=protocol)
        cls.save_option_state = False
        return val
630512
def save_pickle(obj, outfile, protocol=2):
    
    with open(outfile, 'wb') as f:
        pickle.dump(obj, f, protocol=protocol)

    return outfile
241349
def _dump(file_obj, options, out=sys.stdout):
    """"""
    # writer and keys are lazily loaded. We don't know the keys until we have
    # the first item. And we need the keys for the csv writer.
    total_count = 0
    writer = None
    keys = None
    for row in DictReader(file_obj, options.col):
        if not keys:
            keys = row.keys()
        if not writer:
            writer = csv.DictWriter(out, keys, delimiter=u'\t', quotechar=u'\'', quoting=csv.QUOTE_MINIMAL) \
                if options.format == 'csv' \
                else JsonWriter(out) if options.format == 'json' \
                else None
        if total_count == 0 and options.format == "csv" and not options.no_headers:
            writer.writeheader()
        if options.limit != -1 and total_count >= options.limit:
            return
        row_unicode = {k: v.decode("utf-8") if isinstance(v, bytes) else v for k, v in row.items()}
        writer.writerow(row_unicode)
        total_count += 1
592977
def save(self, filename='classifier.dump'):
        
        ofile = open(filename,'w+')
        pickle.dump(self.classifier, ofile)
        ofile.close()
1276859
def dump(type, exc):
        
        try:
            return pickle.dumps(type), pickle.dumps(exc)
        except Exception:
            # get UnpickleableException inside the sandbox
            if "__PEX_UNVENDORED__" in __import__("os").environ:
              from setuptools.sandbox import UnpickleableException as cls  # vendor:skip
            else:
              from pex.third_party.setuptools.sandbox import UnpickleableException as cls

            return cls.dump(cls, cls(repr(exc)))
557079
def dump(self, obj, format=None, *, kwargs={}):
        '''
        
        '''
        return dump(self, obj, format=format, kwargs=kwargs)
366613
def dumppickle(obj, fname, protocol=-1):
    
    with open(fname, 'wb') as fout:  # 'b' for binary, needed on Windows
        pickle.dump(obj, fout, protocol=protocol)
227382
def pickle_dumps(self, protocol=None):
        
        strio = StringIO()
        pmg_pickle_dump(self, strio,
                        protocol=self.pickle_protocol if protocol is None
                        else protocol)
        return strio.getvalue()
499271
def obj2bytes(obj, pk_protocol=py23.pk_protocol):
    
    return pickle.dumps(obj, protocol=pk_protocol)
832770
def save(cls,instance,filename):
        """"""
        filename = cls.correct_file_extension(filename)
        try:
            with open(filename,'wb') as f:
                pickle.dump(instance,f,protocol=pickle.HIGHEST_PROTOCOL)
        except MemoryError as e:
            print ('{} occurred, will downsampled the saved file by 20.'
                   .format(type(e).__name__))
            copy_instance = instance.copy()
            copy_instance.H = copy_instance.H[::20,:,:]
            copy_instance.Y = copy_instance.Y[::20,:]
            with open(filename,'wb') as f:
                pickle.dump(copy_instance,f,protocol=pickle.HIGHEST_PROTOCOL)
579391
def dumpb(obj, container_count=False, sort_keys=False, no_float32=True, default=None):
    """"""
    with BytesIO() as fp:
        dump(obj, fp, container_count=container_count, sort_keys=sort_keys, no_float32=no_float32, default=default)
        return fp.getvalue()
611748
def unpickle_file(picklefile, **kwargs):
    """"""
    with open(picklefile, 'rb') as f:
        return pickle.load(f, **kwargs)
846424
def save(self, path):
        
        path = os.path.expandvars(os.path.expanduser(path))
        with open(path, "wb") as f:
            pickle.dump(self.roots, f)
911463
def dumpfile(item, path):
    '''
    
    '''
    with io.open(path, 'wb') as fd:
        fd.write(en(item))
236341
def save(self):
        """"""
        if self.save_option == 'curdir':
            model_path = os.path.join(
                os.getcwd(),
                '{}.lcopt'.format(self.name)
            )
        else: # default to appdir
            model_path = os.path.join(
                storage.model_dir,
                '{}.lcopt'.format(self.name)
            )
        
        model_path = fix_mac_path_escapes(model_path)

        with open(model_path, 'wb') as model_file:
            pickle.dump(self, model_file)
775988
def dump_index(self, obj):
        """"""
        if isinstance(obj, PIDNodeOrdered) and self._is_child(obj):
            return obj.index(self.context['pid'])
        else:
            return None
1024936
def save(params):
    
    if is_python3():
        import pickle
        cPickle = pickle
    else:
        import cPickle
    ts = datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d_%H-%M-%S")
    if not os.path.exists("saves/"):
        os.makedirs("saves/")
    with open("saves/almonds_%s.params" % ts, "wb") as f:
        cPickle.dump(params, f)
        params.log("Current scene saved!")