]> granicus.if.org Git - python/commitdiff
Change Pickler._batch_appends() and Pickler._batch_setitems() to take
authorAlexandre Vassalotti <alexandre@peadrop.com>
Wed, 14 May 2008 21:57:18 +0000 (21:57 +0000)
committerAlexandre Vassalotti <alexandre@peadrop.com>
Wed, 14 May 2008 21:57:18 +0000 (21:57 +0000)
an iterable object, instead of an iterator.

Lib/pickle.py

index bf5c9513149fdbdcb729a43af31359e7dcee524b..25ffd031485eb456a03658f8d63d874ee42d1c7c 100644 (file)
@@ -594,7 +594,7 @@ class Pickler:
             write(MARK + LIST)
 
         self.memoize(obj)
-        self._batch_appends(iter(obj))
+        self._batch_appends(obj)
 
     dispatch[list] = save_list
 
@@ -611,6 +611,7 @@ class Pickler:
                 write(APPEND)
             return
 
+        items = iter(items)
         r = range(self._BATCHSIZE)
         while items is not None:
             tmp = []
@@ -641,7 +642,7 @@ class Pickler:
             write(MARK + DICT)
 
         self.memoize(obj)
-        self._batch_setitems(iter(obj.items()))
+        self._batch_setitems(obj.items())
 
     dispatch[dict] = save_dict
     if PyStringMap is not None:
@@ -659,6 +660,7 @@ class Pickler:
                 write(SETITEM)
             return
 
+        items = iter(items)
         r = range(self._BATCHSIZE)
         while items is not None:
             tmp = []