This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients belopolsky, ethan.furman, lemburg, mdcb808@gmail.com, vstinner
Date 2014-12-18.17:57:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1418925440.08.0.536145940404.issue23084@psf.upfronthosting.co.za>
In-reply-to
Content
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.

[1] http://pubs.opengroup.org/onlinepubs/7908799/xsh/time.h.html
History
Date User Action Args
2014-12-18 17:57:20belopolskysetrecipients: + belopolsky, lemburg, vstinner, ethan.furman, mdcb808@gmail.com
2014-12-18 17:57:20belopolskysetmessageid: <1418925440.08.0.536145940404.issue23084@psf.upfronthosting.co.za>
2014-12-18 17:57:20belopolskylinkissue23084 messages
2014-12-18 17:57:19belopolskycreate