shelve implementation
Robin Becker
robin at jessikat.demon.co.uk
Mon Jan 31 11:34:36 EST 2000
can someone explain why shelve uses StringIO as an intermediate rather
than doing the pickles direct
ie shelve uses
def __getitem__(self, key):
f = StringIO(self.dict[key])
return Unpickler(f).load()
def __setitem__(self, key, value):
f = StringIO()
p = Pickler(f)
p.dump(value)
self.dict[key] = f.getvalue()
whereas I would have done
def __getitem__(self, key):
return loads(self.dict[key])
def __setitem__(self, key, value):
self.dict[key] = dumps(value)
--
Robin Becker
More information about the Python-list
mailing list