[Python-Dev] Subsecond time stamps

Martin v. Loewis martin@v.loewis.de
06 Sep 2002 17:40:51 +0200


Paul Svensson <paul-python@svensson.org> writes:

> This seems to me the most Pythonic way.
> Are C doubles dense enough to offer 100 ns resolution ?

It looks like they are:

>>> time.time()
1031326478.373606
>>> 1031326478 + 1e-6
1031326478.000001
>>> 1031326478 + 1e-7
1031326478.0000001
>>> 1031326478 + 1e-8
1031326478.0

but only just so:
>>> 1031326478 + 2e-7
1031326478.0000002
>>> 1031326478 + 3e-7
1031326478.0000004
>>> 1031326478 + 4e-7
1031326478.0000004

I admit that this looks tempting, but I'm worried about applications
that break because they expect time stamps in struct stat to be
integers.

Regards,
Martin