Author belopolsky
Recipients Arfrever, Niklas.Claesson, Ramchandra Apte, andrewclegg, belopolsky, goshawk, lemburg, pitrou, r.david.murray, tim.peters, vstinner
Date 2014-07-15.01:37:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1405388258.52.0.113863626436.issue15443@psf.upfronthosting.co.za>
In-reply-to
Content
> (there's no room for an extra 10 bits in the
> carefully arranged 8-byte internal representation)

According to a comment on top of Include/datetime.h, the internal representation of datetime is 10, not 8 bytes.


/* Fields are packed into successive bytes, each viewed as unsigned and
 * big-endian, unless otherwise noted:
 *
 * byte offset
 *  0           year     2 bytes, 1-9999
 *  2           month    1 byte, 1-12
 *  3           day      1 byte, 1-31
 *  4           hour     1 byte, 0-23
 *  5           minute   1 byte, 0-59
 *  6           second   1 byte, 0-59
 *  7           usecond  3 bytes, 0-999999
 * 10
 */

(if you don't trust the comments check the definitions a few lines below)

#define _PyDateTime_DATETIME_DATASIZE 10

AFAIK, Python objects are allocated with at least 32-bit alignment, so we have at least 2 unused bytes at the end of each datetime object.

Furthermore, out of 24 bits allocated for microseconds, only 20 are used, so nanoseconds can be accommodated by adding a single byte to DATETIME_DATASIZE.
History
Date User Action Args
2014-07-15 01:37:38belopolskysetrecipients: + belopolsky, lemburg, tim.peters, pitrou, vstinner, Arfrever, r.david.murray, andrewclegg, Ramchandra Apte, goshawk, Niklas.Claesson
2014-07-15 01:37:38belopolskysetmessageid: <1405388258.52.0.113863626436.issue15443@psf.upfronthosting.co.za>
2014-07-15 01:37:38belopolskylinkissue15443 messages
2014-07-15 01:37:37belopolskycreate