[Python-checkins] python/nondist/sandbox/pickletools pickletools.py,1.32,1.33
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Mon, 27 Jan 2003 08:25:26 -0800
Update of /cvsroot/python/python/nondist/sandbox/pickletools
In directory sc8-pr-cvs1:/tmp/cvs-serv25249
Modified Files:
pickletools.py
Log Message:
Added some pickle disassemblies of recursive objects to the dis test.
Index: pickletools.py
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/pickletools/pickletools.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** pickletools.py 27 Jan 2003 15:38:14 -0000 1.32
--- pickletools.py 27 Jan 2003 16:25:22 -0000 1.33
***************
*** 1705,1708 ****
--- 1705,1766 ----
48: e APPENDS (MARK at 3)
49: . STOP
+
+ Try "the canonical" recursive-object test.
+ >>> L = []
+ >>> T = L,
+ >>> L.append(T)
+ >>> L[0] is T
+ True
+ >>> T[0] is L
+ True
+ >>> L[0][0] is L
+ True
+ >>> T[0][0] is T
+ True
+ >>> dis(pickle.dumps(L))
+ 0: ( MARK
+ 1: l LIST (MARK at 0)
+ 2: p PUT 0
+ 5: ( MARK
+ 6: g GET 0
+ 9: t TUPLE (MARK at 5)
+ 10: p PUT 1
+ 13: a APPEND
+ 14: . STOP
+ >>> dis(pickle.dumps(L, 1))
+ 0: ] EMPTY_LIST
+ 1: q BINPUT 0
+ 3: ( MARK
+ 4: h BINGET 0
+ 6: t TUPLE (MARK at 3)
+ 7: q BINPUT 1
+ 9: a APPEND
+ 10: . STOP
+ >>> dis(pickle.dumps(T))
+ 0: ( MARK
+ 1: ( MARK
+ 2: l LIST (MARK at 1)
+ 3: p PUT 0
+ 6: ( MARK
+ 7: g GET 0
+ 10: t TUPLE (MARK at 6)
+ 11: p PUT 1
+ 14: a APPEND
+ 15: 0 POP
+ 16: 0 POP
+ 17: g GET 1
+ 20: . STOP
+ >>> dis(pickle.dumps(T, 1))
+ 0: ( MARK
+ 1: ] EMPTY_LIST
+ 2: q BINPUT 0
+ 4: ( MARK
+ 5: h BINGET 0
+ 7: t TUPLE (MARK at 4)
+ 8: q BINPUT 1
+ 10: a APPEND
+ 11: 1 POP_MARK (MARK at 0)
+ 12: h BINGET 1
+ 14: . STOP
"""