[Python-checkins] python/dist/src/Lib pickle.py,1.90,1.91
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Mon, 27 Jan 2003 17:15:49 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv27565/Lib
Modified Files:
pickle.py
Log Message:
save_list(): Rewrote, to untangle the proto 0 from the proto 1 cases.
The code is much easier to follow now, and I bet it's faster too.
Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** pickle.py 28 Jan 2003 01:07:48 -0000 1.90
--- pickle.py 28 Jan 2003 01:15:46 -0000 1.91
***************
*** 484,505 ****
if self.bin:
write(EMPTY_LIST)
! else:
! write(MARK + LIST)
!
! self.memoize(object)
!
! using_appends = (self.bin and (len(object) > 1))
!
! if using_appends:
! write(MARK)
!
! for element in object:
! save(element)
! if not using_appends:
write(APPEND)
- if using_appends:
- write(APPENDS)
dispatch[ListType] = save_list
--- 484,507 ----
if self.bin:
write(EMPTY_LIST)
! self.memoize(object)
! n = len(object)
! if n > 1:
! write(MARK)
! for element in object:
! save(element)
! write(APPENDS)
! elif n:
! assert n == 1
! save(object[0])
! write(APPEND)
! # else the list is empty, and we're already done
! else: # proto 0 -- can't use EMPTY_LIST or APPENDS
! write(MARK + LIST)
! self.memoize(object)
! for element in object:
! save(element)
write(APPEND)
dispatch[ListType] = save_list