shelve implementation
Robin Becker
robin at jessikat.demon.co.uk
Mon Jan 31 11:34:36 EST 2000
More information about the Python-list mailing list
Mon Jan 31 11:34:36 EST 2000
- Previous message (by thread): IOError: (0,"Error") when closing "os.popen"ed file?
- Next message (by thread): Reading pipermail archives with mutt
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): IOError: (0,"Error") when closing "os.popen"ed file?
- Next message (by thread): Reading pipermail archives with mutt
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list