Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] PEP 410 (Decimal timestamp): the implementation is ready for a review

Antoine Pitrousolipsis at pitrou.net
Thu Feb 16 13:56:41 CET 2012


On Thu, 16 Feb 2012 13:46:18 +0100Victor Stinner <victor.stinner at gmail.com> wrote:>> Let's try in a ext4 filesystem:>> $ ~/prog/python/timestamp/python> Python 3.3.0a0 (default:35d6cc531800+, Feb 16 2012, 13:32:56)> >>> import decimal, os, shutil, time> >>> open("test", "x").close()> >>> shutil.copy2("test", "test2")> >>> os.stat("test", timestamp=decimal.Decimal).st_mtime> Decimal('1329395871.874886224')> >>> os.stat("test2", timestamp=decimal.Decimal).st_mtime> Decimal('1329395871.873350282')This looks fishy. Floating-point numbers are precise enough torepresent the difference between these two numbers:>>> f = 1329395871.874886224>>> f.hex()'0x1.3cf3e27f7fe23p+30'>>> g = 1329395871.873350282>>> g.hex()'0x1.3cf3e27f7e4f9p+30'If I run your snippet and inspect modification times using `stat`, thedifference is much smaller (around 10 ns, not 1 ms):$ stat test | \grep ModifyModify: 2012-02-16 13:51:25.643597139 +0100$ stat test2 | \grep ModifyModify: 2012-02-16 13:51:25.643597126 +0100In other words, you should check your PEP implementation for bugs.RegardsAntoine.


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp