[Python-checkins] python/dist/src/Lib pickle.py,1.86,1.87

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Mon, 27 Jan 2003 17:00:41 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv17145/Lib

Modified Files:
	pickle.py 
Log Message:
Several routines appeared to inline the guts of memoize(), possibly for
some notion of low-level efficiency.  Undid that, but left one routine
alone:  save_inst() claims it has a reason for not using memoize().
I don't understand that comment, so added an XXX comment there.


Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.86
retrieving revision 1.87
diff -C2 -d -r1.86 -r1.87
*** pickle.py	28 Jan 2003 00:48:09 -0000	1.86
--- pickle.py	28 Jan 2003 01:00:38 -0000	1.87
***************
*** 216,223 ****
          # scheme allows the Unpickler memo to be implemented as a plain (but
          # growable) array, indexed by memo key.
-         d = id(obj)
          memo_len = len(self.memo)
          self.write(self.put(memo_len))
!         self.memo[d] = memo_len, obj
  
      # Return a PUT (BINPUT, LONG_BINPUT) opcode string, with argument i.
--- 216,222 ----
          # scheme allows the Unpickler memo to be implemented as a plain (but
          # growable) array, indexed by memo key.
          memo_len = len(self.memo)
          self.write(self.put(memo_len))
!         self.memo[id(obj)] = memo_len, obj
  
      # Return a PUT (BINPUT, LONG_BINPUT) opcode string, with argument i.
***************
*** 326,332 ****
  
          self.save_reduce(callable, arg_tup, state)
!         memo_len = len(memo)
!         self.write(self.put(memo_len))
!         memo[d] = (memo_len, object)
  
      def persistent_id(self, object):
--- 325,329 ----
  
          self.save_reduce(callable, arg_tup, state)
!         self.memoize(object)
  
      def persistent_id(self, object):
***************
*** 473,479 ****
              return
  
!         memo_len = len(memo)
!         self.write(TUPLE + self.put(memo_len))
!         memo[d] = (memo_len, object)
  
      dispatch[TupleType] = save_tuple
--- 470,475 ----
              return
  
!         self.write(TUPLE)
!         self.memoize(object)
  
      dispatch[TupleType] = save_tuple
***************
*** 567,570 ****
--- 563,569 ----
          # This method does not use memoize() so that it can handle
          # the special case for non-binary mode.
+         # XXX What did that comment mean?  That is, what "special case for
+         # XXX non-binary mode?  It sure *looks* like nothing special is
+         # XXX happening in the INST case.
          memo_len = len(memo)
          if self.bin:
***************
*** 613,620 ****
                      (object, module, name))
  
!         memo_len = len(memo)
!         write(GLOBAL + module + '\n' + name + '\n' +
!             self.put(memo_len))
!         memo[id(object)] = (memo_len, object)
      dispatch[ClassType] = save_global
      dispatch[FunctionType] = save_global
--- 612,617 ----
                      (object, module, name))
  
!         write(GLOBAL + module + '\n' + name + '\n')
!         self.memoize(object)
      dispatch[ClassType] = save_global
      dispatch[FunctionType] = save_global