[Python-checkins] python/dist/src/Lib pickle.py,1.91,1.92
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Mon, 27 Jan 2003 17:34:48 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv7730/Lib
Modified Files:
pickle.py
Log Message:
save_dict(): Untangled most of the bin-vs-not-bin logic. Also used
iteritems() instead of materializing a (possibly giant) list of the
items.
Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.91
retrieving revision 1.92
diff -C2 -d -r1.91 -r1.92
*** pickle.py 28 Jan 2003 01:15:46 -0000 1.91
--- pickle.py 28 Jan 2003 01:34:43 -0000 1.92
***************
*** 509,535 ****
write = self.write
save = self.save
if self.bin:
write(EMPTY_DICT)
! else:
! write(MARK + DICT)
!
! self.memoize(object)
!
! using_setitems = (self.bin and (len(object) > 1))
! if using_setitems:
! write(MARK)
! items = object.items()
for key, value in items:
save(key)
save(value)
!
! if not using_setitems:
! write(SETITEM)
!
! if using_setitems:
! write(SETITEMS)
dispatch[DictionaryType] = save_dict
--- 509,534 ----
write = self.write
save = self.save
+ items = object.iteritems()
if self.bin:
write(EMPTY_DICT)
! self.memoize(object)
! if len(object) > 1:
! write(MARK)
! for key, value in items:
! save(key)
! save(value)
! write(SETITEMS)
! return
! else: # proto 0 -- can't use EMPTY_DICT or SETITEMS
! write(MARK + DICT)
! self.memoize(object)
! # proto 0 or len(object) < 2
for key, value in items:
save(key)
save(value)
! write(SETITEM)
dispatch[DictionaryType] = save_dict