[Python-Dev] PEP 495 accepted (original) (raw)

Alexander Belopolsky alexander.belopolsky at gmail.com
Thu Sep 24 05:07:27 CEST 2015


[Tim Peters] > > Guido's reply gave a clearer invariant: > > dt.timestamp() == > dt.astimezone(utc).timestamp() == > dt.astimezone().timestamp() [ Nick Coghlan]

Might it be worth mentioning Guido's invariant in the section of the PEP about the timestamp method? The case of missing time in Guido's invariant is rather subtle. What is happening is that .timestamp() and .astimezone(..) methods use the same "normalization" to interpret what dt means. This is not obvious in the expression above. Particularly in dt.astimezone().timestamp(). Here, if instead of we pass dt.tzinfo, then .astimezone(..) becomes a noop and "normalization" happens in .timestamp(). I don't think exposing all this in the PEP will help. Let's return to this when it is time to write the reference documentation. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150923/35c9935d/attachment.html>



More information about the Python-Dev mailing list