@@ -21,6 +21,15 @@ func time_time(self py.Object) (py.Object, error) {
2121 return py .Float (time .Now ().UnixNano ()) / 1e9 , nil
2222}
2323
24+ const time_ns_doc = `time_ns() -> int
25+
26+ Return the current time in nanoseconds since the Epoch.
27+ `
28+
29+ func time_time_ns (self py.Object ) (py.Object , error ) {
30+ return py .Int (time .Now ().UnixNano ()), nil
31+ }
32+
2433// func floatclock(_Py_clock_info_t *info) (py.Object, error) {
2534// value := clock()
2635// if value == (clock_t)-1 {
@@ -979,6 +988,7 @@ func PyInit_timezone(m py.Object) {
979988func init () {
980989 methods := []* py.Method {
981990 py .MustNewMethod ("time" , time_time , 0 , time_doc ),
991+ py .MustNewMethod ("time_ns" , time_time_ns , 0 , time_ns_doc ),
982992 py .MustNewMethod ("clock" , time_clock , 0 , clock_doc ),
983993 py .MustNewMethod ("clock_gettime" , time_clock_gettime , 0 , clock_gettime_doc ),
984994 py .MustNewMethod ("clock_settime" , time_clock_settime , 0 , clock_settime_doc ),
@@ -1037,6 +1047,7 @@ tzname -- tuple of (standard time zone name, DST time zone name)
10371047Functions:
10381048
10391049time() -- return current time in seconds since the Epoch as a float
1050+ time_ns() -- return current time in nanoseconds since the Epoch
10401051clock() -- return CPU time since process start as a float
10411052sleep() -- delay for a number of seconds given as a float
10421053gmtime() -- convert seconds since Epoch to UTC tuple
0 commit comments