[Python-checkins] python/dist/src/Lib pickle.py,1.91,1.92

Neal Norwitz neal@metaslash.com
Mon, 27 Jan 2003 22:04:18 -0500


> !         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

In the case where self.bin and len(object) == 1, the code looks
like it does something different.

The old code would save(key) & save(value) since the for loop is
executed.  The new code doesn't execute the loop though.

Am I missing something?

Neal