@@ -21,6 +21,15 @@ func time_time(self py.Object) (py.Object, error) {
21
21
return py .Float (time .Now ().UnixNano ()) / 1e9 , nil
22
22
}
23
23
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
+
24
33
// func floatclock(_Py_clock_info_t *info) (py.Object, error) {
25
34
// value := clock()
26
35
// if value == (clock_t)-1 {
@@ -979,6 +988,7 @@ func PyInit_timezone(m py.Object) {
979
988
func init () {
980
989
methods := []* py.Method {
981
990
py .MustNewMethod ("time" , time_time , 0 , time_doc ),
991
+ py .MustNewMethod ("time_ns" , time_time_ns , 0 , time_ns_doc ),
982
992
py .MustNewMethod ("clock" , time_clock , 0 , clock_doc ),
983
993
py .MustNewMethod ("clock_gettime" , time_clock_gettime , 0 , clock_gettime_doc ),
984
994
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)
1037
1047
Functions:
1038
1048
1039
1049
time() -- return current time in seconds since the Epoch as a float
1050
+ time_ns() -- return current time in nanoseconds since the Epoch
1040
1051
clock() -- return CPU time since process start as a float
1041
1052
sleep() -- delay for a number of seconds given as a float
1042
1053
gmtime() -- convert seconds since Epoch to UTC tuple
0 commit comments