[Python-checkins] python/nondist/sandbox/datetime obj_delta.c,1.14,1.15 test_both.py,1.15,1.16

Tim Peters tim.one@comcast.net
Mon, 02 Dec 2002 21:35:26 -0500


[Fred L. Drake, Jr.]
> You might be able to work with the copy_reg module instead of using
> __reduce__.  That's what I did for the parser module
> (Modules/parsermodule.c).  I don't know if that'll work for new-style
> objects.

It works, and I checked it in, but I'm not sure it's an improvement -- the
pickler function still needs to produce a tuple with an embedded tuple, and
the name of the unpickling function ends up in the pickle too.

>>> from _datetime import *
>>> import pickle
>>> len(pickle.dumps(date(1, 1, 1), 1))
45
>>>

The *state* of the date object is 4 bytes.  It's hard to swallow that
administrative pickle bloat consumes 41 additional bytes.

OTOH, it's a lot better than the bloat in the Python implementation:

>>> import datetime
>>> d = datetime.date(1, 1, 1)
>>> len(pickle.dumps(d, 1))
84
>>>