[Python-checkins] python/dist/src/Lib pickle.py,1.119,1.120 pickletools.py,1.17,1.18
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Tue, 28 Jan 2003 16:56:19 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv28373/Lib
Modified Files:
pickle.py pickletools.py
Log Message:
pickle: Comment repair.
pickletools: Import decode_long from pickle instead of duplicating it.
Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.119
retrieving revision 1.120
diff -C2 -d -r1.119 -r1.120
*** pickle.py 28 Jan 2003 22:31:25 -0000 1.119
--- pickle.py 29 Jan 2003 00:56:17 -0000 1.120
***************
*** 38,42 ****
"Unpickler", "dump", "dumps", "load", "loads"]
! # These are purely informational; no code usues these
format_version = "2.0" # File format version we write
compatible_formats = ["1.0", # Original protocol 0
--- 38,42 ----
"Unpickler", "dump", "dumps", "load", "loads"]
! # These are purely informational; no code uses these.
format_version = "2.0" # File format version we write
compatible_formats = ["1.0", # Original protocol 0
***************
*** 48,52 ****
# Why use struct.pack() for pickling but marshal.loads() for
! # unpickling? struct.pack() is 40% faster than marshal.loads(), but
# marshal.loads() is twice as fast as struct.unpack()!
mloads = marshal.loads
--- 48,52 ----
# Why use struct.pack() for pickling but marshal.loads() for
! # unpickling? struct.pack() is 40% faster than marshal.dumps(), but
# marshal.loads() is twice as fast as struct.unpack()!
mloads = marshal.loads
***************
*** 74,77 ****
--- 74,79 ----
pass
+ # An instance of _Stop is raised by Unpickler.load_stop() in response to
+ # the STOP opcode, passing the object that is the result of unpickling.
class _Stop(Exception):
def __init__(self, value):
***************
*** 139,143 ****
FALSE = 'I00\n' # not an opcode; see INT docs in pickletools.py
! # Protocol 2 (not yet implemented).
PROTO = '\x80' # identify pickle protocol
--- 141,145 ----
FALSE = 'I00\n' # not an opcode; see INT docs in pickletools.py
! # Protocol 2 (XXX not yet implemented).
PROTO = '\x80' # identify pickle protocol
***************
*** 773,776 ****
--- 775,781 ----
+ # A cache for whichmodule(), mapping a function object to the name of
+ # the module in which the function was found.
+
classmap = {} # called classmap for backwards compatibility
***************
*** 781,785 ****
Cache in classmap.
Return a module name.
! If the function cannot be found, return __main__.
"""
if func in classmap:
--- 786,790 ----
Cache in classmap.
Return a module name.
! If the function cannot be found, return "__main__".
"""
if func in classmap:
Index: pickletools.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickletools.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** pickletools.py 28 Jan 2003 16:01:25 -0000 1.17
--- pickletools.py 29 Jan 2003 00:56:17 -0000 1.18
***************
*** 604,630 ****
# Protocol 2 formats
! def decode_long(data):
! r"""Decode a long from a two's complement little-endian binary string.
! >>> decode_long("\xff\x00")
! 255L
! >>> decode_long("\xff\x7f")
! 32767L
! >>> decode_long("\x00\xff")
! -256L
! >>> decode_long("\x00\x80")
! -32768L
! >>> decode_long("\x80")
! -128L
! >>> decode_long("\x7f")
! 127L
! """
! x = 0L
! i = 0L
! for c in data:
! x |= long(ord(c)) << i
! i += 8L
! if data and ord(c) >= 0x80:
! x -= 1L << i
! return x
def read_long1(f):
--- 604,608 ----
# Protocol 2 formats
! from pickle import decode_long
def read_long1(f):
***************
*** 1794,1797 ****
--- 1772,1776 ----
assure_pickle_consistency()
+ del assure_pickle_consistency
##############################################################################