PEP 495: New pickle format.

This commit is contained in:
Alexander Belopolsky 2015-09-20 23:17:33 -04:00
parent 6e5376dde9
commit e4087c70ad
1 changed files with 10 additions and 6 deletions

View File

@ -288,14 +288,18 @@ The ``datetime.datetime.time()`` method will copy the value of the
Pickles Pickles
....... .......
The value of the fold attribute will only be saved in pickles created
with protocol version 4 (introduced in Python 3.4) or greater.
Pickle sizes for the ``datetime.datetime`` and ``datetime.time`` Pickle sizes for the ``datetime.datetime`` and ``datetime.time``
objects will not change. The ``fold`` value will be encoded in the objects will not change. The ``fold`` value will be encoded in the
first bit of the 5th byte of the ``datetime.datetime`` pickle payload first bit of the 3rd (1st) byte of ``datetime.datetime``
or the 2nd byte of the datetime.time. In the `current implementation`_ (``datetime.time``) pickle payload. In the `current implementation`_
these bytes are used to store minute value (0-59) and the first bit is these byte are used to store the month (1-12) and hour (0-23) values
always 0. (This change only affects pickle format. In the C and the first bit is always 0. We picked these bytes because they are
implementation, the ``fold`` attribute will get a full byte to store its the only bytes that are checked by the current unpickle code. Thus
value.) loading post-PEP ``fold=1`` pickles in a pre-PEP Python will result in
an exception rather than an instance with out of range components.
.. _current implementation: https://hg.python.org/cpython/file/d3b20bff9c5d/Include/datetime.h#l17 .. _current implementation: https://hg.python.org/cpython/file/d3b20bff9c5d/Include/datetime.h#l17