Author belopolsky
Recipients belopolsky, ethan.furman, lemburg,, vstinner
Date 2014-12-18.17:57:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
See also discussion in #9079, #14127 and #14180.  At some point there was some resistance to use capsule mechanism to share code within stdlib and the functions that were shared between time and datetime modules were moved to the core.

I am -1 on adding struct_timespec type.

POSIX defines [1] the following functions that take struct timespec:

int        clock_getres(clockid_t, struct timespec *);
int        clock_gettime(clockid_t, struct timespec *);
int        clock_settime(clockid_t, const struct timespec *);
int        nanosleep(const struct timespec *, struct timespec *);

and a pair of timer functions that take timespec indirectly through itimerspec struct:

int        timer_gettime(timer_t, struct itimerspec *);
int        timer_settime(timer_t, int, const struct itimerspec *,
               struct itimerspec *);

In addition, struct stat provides timespec members on some systems.

There was a long discussion on how to represent high precession time in Python.  PEP 410 proposed using the decimal type and it was rejected.

Nanosecond support was ultimately added to os.struct() by adding integer st_{a,m,c}time_ns members.  See #14127.

Interface to nanosleep is already available via time.sleep() function.  If we ever need higher precision sleep we can add time.nanosleep() that takes time in nanoseconds.  We have a similar story with time.clock().

Overall, the proposed type is much less convenient than integer nanoseconds because it does not support arithmetics. 

In any case, I think it is premature to discuss adding a new type before some functions are proposed that would produce or consume instances of this type.

Date User Action Args
2014-12-18 17:57:20belopolskysetrecipients: + belopolsky, lemburg, vstinner, ethan.furman,
2014-12-18 17:57:20belopolskysetmessageid: <>
2014-12-18 17:57:20belopolskylinkissue23084 messages
2014-12-18 17:57:19belopolskycreate