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

Guido van Rossum guido at python.org
Wed Feb 15 19:11:42 CET 2012


So using floats we can match 100ns precision, right?

On Wed, Feb 15, 2012 at 9:58 AM, Victor Stinner <victor.stinner at gmail.com> wrote:

Linux supports nanosecond timestamps since Linux 2.6, Windows supports 100 ns resolution since Windows 2000 or maybe before. It doesn't mean that Windows system clock is accurate: in practical, it's hard to get something better than 1 ms :-)

Well, do you think the Linux system clock is nanosecond-accurate? Test the following C program: ------------ #include <stdio.h> #include <time.h> int main(int argc, char **argv, char **arge) {  struct timespec tps, tpe;  if ((clockgettime(CLOCKREALTIME, &tps) != 0)  || (clockgettime(CLOCKREALTIME, &tpe) != 0)) {  perror("clockgettime");  return -1;  }  printf("%lu s, %lu ns\n", tpe.tvsec-tps.tvsec,  tpe.tvnsec-tps.tvnsec);  return 0; } ------------ Compile it using gcc time.c -o time -lrt. It gives me differences smaller than 1000 ns on Ubuntu 11.10 and a Intel Core i5 @ 3.33GHz: $ ./a.out 0 s, 781 ns $ ./a.out 0 s, 785 ns $ ./a.out 0 s, 798 ns $ ./a.out 0 s, 818 ns $ ./a.out 0 s, 270 ns Victor


Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

-- --Guido van Rossum (python.org/~guido)



More information about the Python-Dev mailing list