Tim Peters
a6ae9a2128
save_empty_tuple(): Comment on why we can't get rid of this.
2003-01-28 16:58:41 +00:00
Tim Peters
82ca59e002
save_dict(): Added a comment about the control flow NealN missed.
2003-01-28 16:47:59 +00:00
Tim Peters
13a25fb8e6
_is_string_secure(): This method is no longer used; removed it. (It
...
was used before string-escape codecs were added to the core.)
2003-01-28 16:42:22 +00:00
Guido van Rossum
bc64e22ed6
Made save() fit on a page, while adding comments. (I moved some type
...
checks to save_reduce(), which can also be called from a subclass.)
Also tweaked some more comments.
2003-01-28 16:34:19 +00:00
Tim Peters
ad5a771fae
Got rid of the _quotes global. Used only once, and is trivial.
2003-01-28 16:23:33 +00:00
Guido van Rossum
1be3175992
Add a few comments. Change the way the protocol is checked (it must
...
be one of 0, 1 or 2).
I should note that the previous checkin also added NEWOBJ support to
the unpickler -- but there's nothing yet that generates this.
2003-01-28 15:19:53 +00:00
Guido van Rossum
3a41c61dd4
Rename all variables 'object' to 'obj' to avoid conflicts with the
...
type 'object'. Also minor docstring tweakage, and rearranged a few
lines in save().
2003-01-28 15:10:22 +00:00
Guido van Rossum
cbe2dbddda
Don't memoize the empty tuple in protocol 0.
2003-01-28 14:40:16 +00:00
Tim Peters
d97da80dd5
save_tuple(): So long as the charter is rewriting for clarity, the snaky
...
control flow had to be simplified.
2003-01-28 05:48:29 +00:00
Tim Peters
ff57bff16e
save_tuple(): I believe the new code for TUPLE{1,2,3} in proto 2 was
...
incorrect for recursive tuples. Tried to repair; seems to work OK, but
there are no checked-in tests for this yet.
2003-01-28 05:34:53 +00:00
Guido van Rossum
7d97d31a1b
OK, this is really the last one tonight!
...
NEWFALSE and NEWTRUE.
2003-01-28 04:25:27 +00:00
Guido van Rossum
44f0ea5f73
More protocol 2: TUPLE1, TUPLE2, TUPLE3.
...
Also moved the special case for empty tuples from save() to save_tuple().
2003-01-28 04:14:51 +00:00
Tim Peters
3b769835ca
save_inst(): Rewrote to have only one branch on self.bin. Also got rid
...
of my recent XXX comment, taking a (what appears to be vanishingly small)
chance and calling self.memoize() instead.
2003-01-28 03:51:36 +00:00
Guido van Rossum
d6c9e63af9
First baby steps towards implementing protocol 2: PROTO, LONG1 and LONG4.
2003-01-28 03:49:52 +00:00
Tim Peters
d95c2df3a9
Fixed odd whitespace after "if", which I believe I introduced long ago.
2003-01-28 03:41:54 +00:00
Tim Peters
8fda7bc48d
save_int(): Fixed two new off-by-1 glitches.
2003-01-28 03:40:52 +00:00
Guido van Rossum
e0b904232f
Add a comment explaining that struct.pack() beats marshal.dumps(), but
...
marshal.loads() beats struct.unpack()! Possibly because the latter
creates a one-tuple. :-(
2003-01-28 03:17:21 +00:00
Guido van Rossum
5c938d00a1
Got rid of mdumps; I timed it, and struct.pack("<i", x) is more than
...
40% faster than marshal.dumps(x)[1:]! (That's not counting the
module attribute lookups, which can be avoided in either case.)
2003-01-28 03:03:08 +00:00
Tim Peters
f558da0f90
save_tuple(): Minor rewriting, and added a comment about the subtlety
...
created by recursive tuples.
2003-01-28 02:09:55 +00:00
Tim Peters
209ad95b00
load_appends(): replaced .append() loop with an .extend().
2003-01-28 01:44:45 +00:00
Tim Peters
c23d18a955
Comments.
2003-01-28 01:41:51 +00:00
Tim Peters
064567e41a
save_dict(): Untangled most of the bin-vs-not-bin logic. Also used
...
iteritems() instead of materializing a (possibly giant) list of the
items.
2003-01-28 01:34:43 +00:00
Tim Peters
21c18f0bf5
save_list(): Rewrote, to untangle the proto 0 from the proto 1 cases.
...
The code is much easier to follow now, and I bet it's faster too.
2003-01-28 01:15:46 +00:00
Tim Peters
22dc6f4f7a
save_list(): removed unused local "d".
2003-01-28 01:07:48 +00:00
Tim Peters
58d7846e68
save_list(): removed unused local "memo".
2003-01-28 01:07:10 +00:00
Tim Peters
bd1cdb9227
save_pers(): Switched the order of cases, to get rid of a "not", and to
...
make the bin-vs-not-bin order consistent with what other routines try to
do (they almost all handle the bin case first).
2003-01-28 01:03:10 +00:00
Tim Peters
518df0dae4
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.
2003-01-28 01:00:38 +00:00
Tim Peters
b32a8317d7
save(): Fiddled the control flow to put the normal case where it
...
belongs. This is a much smaller change than it may appear: the bulk
of the function merely got unindented by one level.
2003-01-28 00:48:09 +00:00
Tim Peters
c9d7c4a656
Added XXX about save()'s special-casing of tuples -- I don't get it.
2003-01-28 00:43:26 +00:00
Tim Peters
22987e3cbd
save_bool(): simplified.
2003-01-28 00:26:14 +00:00
Tim Peters
cbd0a32d09
Repaired grammar in new comment.
2003-01-28 00:24:43 +00:00
Tim Peters
b377f8ac3e
clear_memo(): Repaired grammar in docstring.
2003-01-28 00:23:36 +00:00
Tim Peters
e105478a0c
Added one-line comments to the proto 2 opcodes.
2003-01-28 00:22:12 +00:00
Tim Peters
fdb8cfab08
Removed the new LONG2 opcode: it's extravagant. If LONG1 isn't enough,
...
then the embedded argument consumes at least 256 bytes. The difference
between a 3-byte prefix (LONG2 + 2 bytes) and a 5-byte prefix (LONG4 +
4 bytes) is at worst less than 1%. Note that binary strings and binary
Unicode strings also have only "size is 1 byte, or size is 4 bytes?"
flavors, and I expect for the same reason. The only place a 2-byte
thingie was used was in BININT2, where the 2 bytes make up the *entire*
embedded argument (and now EXT2 also does this); that's a large savings
over 4 bytes, because the total opcode+argument size is so small in
the BININT2/EXT2 case.
Removed the TAKEN_FROM_ARGUMENT "number of bytes" code, and bifurcated it
into TAKEN_FROM_ARGUMENT1 and TAKEN_FROM_ARGUMENT4. Now there's enough
info in ArgumentDescriptor objects to deduce the # of bytes consumed by
each opcode.
Rearranged the order in which proto2 opcodes are listed in pickle.py.
2003-01-28 00:13:19 +00:00
Guido van Rossum
f29d3d6011
Begin the change from 'binary vs. text mode' to 'protocol 0, 1, 2'.
...
The protocol now defaults to 1. Protocol 2 is still unimplemented.
2003-01-27 22:47:53 +00:00
Guido van Rossum
5a2d8f5e9a
Begin documenting protocol 2.
2003-01-27 21:44:25 +00:00
Tim Peters
bb38e306ae
Added some comments.
2003-01-27 21:25:41 +00:00
Tim Peters
e46b73f5b3
memoize(): Reworded the docs to try to disentangle the Pickler's memo
...
dict from the Unpickler's memo (which is a different beast!).
2003-01-27 21:22:10 +00:00
Tim Peters
bbf63cd05c
Using marshal functions to pack & unpack 1-byte ints is an obscure &
...
expensive way to spell chr() and ord().
2003-01-27 21:15:36 +00:00
Tim Peters
22a449aacc
Added a brief comment to each pickle opcode declaration.
2003-01-27 20:16:36 +00:00
Jeremy Hylton
3422c99de1
Raise PicklingError when __reduce__() fails, and
...
add memoize() helper function to update the memo.
The first element of the tuple returned by __reduce__() must be a
callable. If it isn't the Unpickler will raise an error. Catch this
error in the pickler and raise the error there.
The memoize() helper also has a comment explaining how the memo
works. So methods can't use memoize() because the write funny codes.
2003-01-24 19:29:52 +00:00
Jeremy Hylton
5e0f4e73a9
Remove inst_persistent_id() WANNI (we ain't never needed it).
...
Add some simple tests of the persistence hooks.
2002-11-13 22:01:27 +00:00
Jeremy Hylton
f0cfdf7314
Fiddle comments and variable names in whichmodule().
2002-09-19 23:00:12 +00:00
Jeremy Hylton
065a5ab8fb
whichmodule() should skip dummy package entries in sys.modules.
...
This fixes the charming, but unhelpful error message for
>>> pickle.dumps(type.__new__)
Can't pickle <built-in method __new__ of type object at 0x812a440>: it's not the same object as datetime.math.__new__
Bugfix candidate.
2002-09-19 22:57:26 +00:00
Martin v. Löwis
8a8da798a5
Patch #505705 : Remove eval in pickle and cPickle.
2002-08-14 07:46:28 +00:00
Jeremy Hylton
39c6116483
Given the persistent id code a shot at a class before calling save_global().
...
Some persistent picklers (well, probably, the *only* persistent
pickler) would like to pickle some classes in a special way.
2002-07-16 19:47:43 +00:00
Raymond Hettinger
46ac8eb3c8
Code modernization. Replace v=s[i]; del s[i] with single lookup v=s.pop(i)
2002-06-30 03:39:14 +00:00
Raymond Hettinger
54f0222547
SF 563203. Replaced 'has_key()' with 'in'.
2002-06-01 14:18:47 +00:00
Neal Norwitz
efbb67b1a7
Remove comment about inheritance, look one line up
2002-05-30 12:12:04 +00:00
Raymond Hettinger
aef22fb9cd
Patch 560023 adding docstrings. 2.2 Candidate (after verifying modules were not updated after 2.2).
2002-05-29 16:18:42 +00:00