Author vstinner
Recipients ammar2, bmwiedemann, matrixise, vstinner, xtreak
Date 2020-04-29.17:13:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1588180396.81.0.0782443578253.issue34990@roundup.psfhosted.org>
In-reply-to
Content
I would prefer to mimick importlib._bootstrap_external which uses:

def _pack_uint32(x):
    """Convert a 32-bit integer to little-endian."""
    return (int(x) & 0xFFFFFFFF).to_bytes(4, 'little')

Using 64-bit timestamp (PR 19651), treat timestamp as unsigned (PR 9892 and PR 19708) have drawback:

* 64-bit timestamp make .pyc files larger
* unsigned timestamp no longer support timestamp before 1969 which can cause practical issues

"& 0xFFFFFFFF" looks dead simple, uses a fixed size of 4 bytes and doesn't have any limitation of year 2038.

The timestamp doesn't have to be exact. In practice, it sounds very unlikely that two timestamps are equal when compared using (ts1 & 0xFFFFFFFF) == (ts2 & 0xFFFFFFFF). I expect file modification times to be close by a few days, not separated by 2**32 seconds (136 years).

Use hash based .pyc to avoid any issuse with file modification time: it should make Python more deterministic (more "reproducible").
https://docs.python.org/dev/reference/import.html#pyc-invalidation
History
Date User Action Args
2020-04-29 17:13:16vstinnersetrecipients: + vstinner, matrixise, bmwiedemann, ammar2, xtreak
2020-04-29 17:13:16vstinnersetmessageid: <1588180396.81.0.0782443578253.issue34990@roundup.psfhosted.org>
2020-04-29 17:13:16vstinnerlinkissue34990 messages
2020-04-29 17:13:16vstinnercreate