On Nov 17, 3:08 pm, [EMAIL PROTECTED] wrote: > Mark> def saveOjb(self, dataObj): > Mark> fName = self.version + '_' + self.modname + '.dat' > Mark> f = open(fName, 'w') > Mark> dStr = pickle.dumps(dataObj) > Mark> c = dStr.encode("bz2") > Mark> pickle.dump(c, f, pickle.HIGHEST_PROTOCOL) > Mark> f.close() > > Hmmm... Why pickle it twice? > > def saveOjb(self, dataObj): > fName = self.version + '_' + self.modname + '.dat' > f = open(fName, 'wb') > f.write(pickle.dumps(dataObj, pickle.HIGHEST_PROTOCOL).encode("bz2")) > f.close() > > Skip
I wasn't sure whether the string object was still a string after "encode" is called... at least whether it's still an ascii string. And if not, whether it could be used w/ dumps. I tested your variation and it works the same. I guess your "write" is doing the same as my "dump", but may be more efficient. Thanks. -- http://mail.python.org/mailman/listinfo/python-list