"spir" <denis.s...@free.fr> wrote

So, python uses C's gettimeofday() func when available

It's not C's function, it's a Unix system call. It's been part of Unix since BSD 4.2

ftime() (millisecond),

Also Unix and predates BSD 4.2...

else it has only plain second precision using time().

Which is an ANSI C function.

But there is no matching system call AFAIK except for time (via datetime in unix-like systems).

time() is the lowest common denominator supported by any ANSI C system.
It returns a tm struct:

struct tm{
   int tm_sec;
   int tm_min;
   // etc up to
   int tm_yday;
   int tm_isdst;
}

So only seconds need to be supported for ANSI compliance.

gettimeofday() is the Unix system call that returns microseconds.

But to confuse things, on Unix there is also the time() library function
(not system call - subtle difference!) which returns a timeval structure:

struct timeval{
   long tv_sec;
   long tv_usec;
}

So even time() on Unix returns microsecs.

But on early DOS it only returns seconds.
(I may be wrong but I think time() on DOS 6 returned milliseconds?)

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to