Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 49a69e4

Browse files
committed
strip is_ prefixes on clock_info fields
1 parent d099b56 commit 49a69e4

5 files changed

Lines changed: 55 additions & 55 deletions

File tree

Doc/library/time.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ The module defines the following functions and data items:
168168

169169
The name of the underlying C function used to get the clock value.
170170

171-
.. attribute:: is_monotonic
171+
.. attribute:: monotonic
172172

173173
``True`` if the clock cannot go backward, ``False`` otherwise.
174174

175-
.. attribute:: is_adjusted
175+
.. attribute:: adjusted
176176

177177
``True`` if the clock can be adjusted (e.g. by a NTP daemon), ``False``
178178
otherwise.

Include/pytime.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ typedef struct {
2525
/* Structure used by time.get_clock_info() */
2626
typedef struct {
2727
const char *implementation;
28-
int is_monotonic;
29-
int is_adjusted;
28+
int monotonic;
29+
int adjusted;
3030
double resolution;
3131
} _Py_clock_info_t;
3232

Lib/test/test_time.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ def test_data_attributes(self):
3030
def test_time(self):
3131
time.time()
3232
info = time.get_clock_info('time')
33-
self.assertEqual(info.is_monotonic, False)
33+
self.assertEqual(info.monotonic, False)
3434
if sys.platform != 'win32':
35-
self.assertEqual(info.is_adjusted, True)
35+
self.assertEqual(info.adjusted, True)
3636

3737
def test_clock(self):
3838
time.clock()
3939

4040
info = time.get_clock_info('clock')
41-
self.assertEqual(info.is_monotonic, True)
42-
self.assertEqual(info.is_adjusted, False)
41+
self.assertEqual(info.monotonic, True)
42+
self.assertEqual(info.adjusted, False)
4343

4444
@unittest.skipUnless(hasattr(time, 'clock_gettime'),
4545
'need time.clock_gettime()')
@@ -370,11 +370,11 @@ def test_monotonic(self):
370370
self.assertAlmostEqual(dt, 0.1, delta=0.2)
371371

372372
info = time.get_clock_info('monotonic')
373-
self.assertEqual(info.is_monotonic, True)
373+
self.assertEqual(info.monotonic, True)
374374
if sys.platform == 'linux':
375-
self.assertEqual(info.is_adjusted, True)
375+
self.assertEqual(info.adjusted, True)
376376
else:
377-
self.assertEqual(info.is_adjusted, False)
377+
self.assertEqual(info.adjusted, False)
378378

379379
def test_perf_counter(self):
380380
time.perf_counter()
@@ -386,8 +386,8 @@ def test_process_time(self):
386386
self.assertLess(stop - start, 0.01)
387387

388388
info = time.get_clock_info('process_time')
389-
self.assertEqual(info.is_monotonic, True)
390-
self.assertEqual(info.is_adjusted, False)
389+
self.assertEqual(info.monotonic, True)
390+
self.assertEqual(info.adjusted, False)
391391

392392
@unittest.skipUnless(hasattr(time, 'monotonic'),
393393
'need time.monotonic')
@@ -433,12 +433,12 @@ def test_get_clock_info(self):
433433
#self.assertIsInstance(info, dict)
434434
self.assertIsInstance(info.implementation, str)
435435
self.assertNotEqual(info.implementation, '')
436-
self.assertIsInstance(info.is_monotonic, bool)
436+
self.assertIsInstance(info.monotonic, bool)
437437
self.assertIsInstance(info.resolution, float)
438438
# 0.0 < resolution <= 1.0
439439
self.assertGreater(info.resolution, 0.0)
440440
self.assertLessEqual(info.resolution, 1.0)
441-
self.assertIsInstance(info.is_adjusted, bool)
441+
self.assertIsInstance(info.adjusted, bool)
442442

443443
self.assertRaises(ValueError, time.get_clock_info, 'xxx')
444444

Modules/timemodule.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ floatclock(_Py_clock_info_t *info)
9595
if (info) {
9696
info->implementation = "clock()";
9797
info->resolution = 1.0 / (double)CLOCKS_PER_SEC;
98-
info->is_monotonic = 1;
99-
info->is_adjusted = 0;
98+
info->monotonic = 1;
99+
info->adjusted = 0;
100100
}
101101
return PyFloat_FromDouble((double)value / CLOCKS_PER_SEC);
102102
}
@@ -131,8 +131,8 @@ win_perf_counter(_Py_clock_info_t *info, PyObject **result)
131131
if (info) {
132132
info->implementation = "QueryPerformanceCounter()";
133133
info->resolution = 1.0 / (double)cpu_frequency;
134-
info->is_monotonic = 1;
135-
info->is_adjusted = 0;
134+
info->monotonic = 1;
135+
info->adjusted = 0;
136136
}
137137
*result = PyFloat_FromDouble(diff / (double)cpu_frequency);
138138
return 0;
@@ -874,15 +874,15 @@ pymonotonic(_Py_clock_info_t *info)
874874
info->implementation = "GetTickCount64()";
875875
else
876876
info->implementation = "GetTickCount()";
877-
info->is_monotonic = 1;
877+
info->monotonic = 1;
878878
ok = GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement,
879879
&isTimeAdjustmentDisabled);
880880
if (!ok) {
881881
PyErr_SetFromWindowsErr(0);
882882
return NULL;
883883
}
884884
info->resolution = timeIncrement * 1e-7;
885-
info->is_adjusted = 0;
885+
info->adjusted = 0;
886886
}
887887
return PyFloat_FromDouble(result);
888888

@@ -902,8 +902,8 @@ pymonotonic(_Py_clock_info_t *info)
902902
if (info) {
903903
info->implementation = "mach_absolute_time()";
904904
info->resolution = (double)timebase.numer / timebase.denom * 1e-9;
905-
info->is_monotonic = 1;
906-
info->is_adjusted = 0;
905+
info->monotonic = 1;
906+
info->adjusted = 0;
907907
}
908908
return PyFloat_FromDouble(secs);
909909

@@ -924,14 +924,14 @@ pymonotonic(_Py_clock_info_t *info)
924924

925925
if (info) {
926926
struct timespec res;
927-
info->is_monotonic = 1;
927+
info->monotonic = 1;
928928
info->implementation = function;
929929
#if (defined(linux) || defined(__linux) || defined(__linux__)) \
930930
&& !defined(CLOCK_HIGHRES)
931931
/* CLOCK_MONOTONIC is adjusted on Linux */
932-
info->is_adjusted = 1;
932+
info->adjusted = 1;
933933
#else
934-
info->is_adjusted = 0;
934+
info->adjusted = 0;
935935
#endif
936936
if (clock_getres(clk_id, &res) == 0)
937937
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
@@ -1023,8 +1023,8 @@ py_process_time(_Py_clock_info_t *info)
10231023
if (info) {
10241024
info->implementation = "GetProcessTimes()";
10251025
info->resolution = 1e-7;
1026-
info->is_monotonic = 1;
1027-
info->is_adjusted = 0;
1026+
info->monotonic = 1;
1027+
info->adjusted = 0;
10281028
}
10291029
return PyFloat_FromDouble(total * 1e-7);
10301030
#else
@@ -1052,8 +1052,8 @@ py_process_time(_Py_clock_info_t *info)
10521052
if (info) {
10531053
struct timespec res;
10541054
info->implementation = function;
1055-
info->is_monotonic = 1;
1056-
info->is_adjusted = 0;
1055+
info->monotonic = 1;
1056+
info->adjusted = 0;
10571057
if (clock_getres(clk_id, &res) == 0)
10581058
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
10591059
else
@@ -1070,8 +1070,8 @@ py_process_time(_Py_clock_info_t *info)
10701070
total += ru.ru_stime.tv_sec + ru.ru_stime.tv_usec * 1e-6;
10711071
if (info) {
10721072
info->implementation = "getrusage(RUSAGE_SELF)";
1073-
info->is_monotonic = 1;
1074-
info->is_adjusted = 0;
1073+
info->monotonic = 1;
1074+
info->adjusted = 0;
10751075
info->resolution = 1e-6;
10761076
}
10771077
return PyFloat_FromDouble(total);
@@ -1099,8 +1099,8 @@ py_process_time(_Py_clock_info_t *info)
10991099
total += (double)t.tms_stime / ticks_per_second;
11001100
if (info) {
11011101
info->implementation = "times()";
1102-
info->is_monotonic = 1;
1103-
info->is_adjusted = 0;
1102+
info->monotonic = 1;
1103+
info->adjusted = 0;
11041104
info->resolution = 1.0 / ticks_per_second;
11051105
}
11061106
return PyFloat_FromDouble(total);
@@ -1132,8 +1132,8 @@ PyDoc_STRVAR(ClockInfo_docstring,
11321132
static PyStructSequence_Field ClockInfo_fields[] = {
11331133
{"implementation", "name of the underlying C function "
11341134
"used to get the clock value"},
1135-
{"is_monotonic", "True if the clock cannot go backward, False otherwise"},
1136-
{"is_adjusted", "True if the clock can be adjusted "
1135+
{"monotonic", "True if the clock cannot go backward, False otherwise"},
1136+
{"adjusted", "True if the clock can be adjusted "
11371137
"(e.g. by a NTP daemon), False otherwise"},
11381138
{"resolution", "resolution of the clock in seconds"},
11391139
{NULL, NULL}
@@ -1159,13 +1159,13 @@ time_get_clock_info(PyObject *self, PyObject *args)
11591159

11601160
#ifdef Py_DEBUG
11611161
info.implementation = NULL;
1162-
info.is_monotonic = -1;
1163-
info.is_adjusted = -1;
1162+
info.monotonic = -1;
1163+
info.adjusted = -1;
11641164
info.resolution = -1.0;
11651165
#else
11661166
info.implementation = "";
1167-
info.is_monotonic = 0;
1168-
info.is_adjusted = 0;
1167+
info.monotonic = 0;
1168+
info.adjusted = 0;
11691169
info.resolution = 1.0;
11701170
#endif
11711171

@@ -1201,14 +1201,14 @@ time_get_clock_info(PyObject *self, PyObject *args)
12011201
goto error;
12021202
PyStructSequence_SET_ITEM(result, 0, obj);
12031203

1204-
assert(info.is_monotonic != -1);
1205-
obj = PyBool_FromLong(info.is_monotonic);
1204+
assert(info.monotonic != -1);
1205+
obj = PyBool_FromLong(info.monotonic);
12061206
if (obj == NULL)
12071207
goto error;
12081208
PyStructSequence_SET_ITEM(result, 1, obj);
12091209

1210-
assert(info.is_adjusted != -1);
1211-
obj = PyBool_FromLong(info.is_adjusted);
1210+
assert(info.adjusted != -1);
1211+
obj = PyBool_FromLong(info.adjusted);
12121212
if (obj == NULL)
12131213
goto error;
12141214
PyStructSequence_SET_ITEM(result, 2, obj);
@@ -1487,8 +1487,8 @@ floattime(_Py_clock_info_t *info)
14871487
if (info) {
14881488
struct timespec res;
14891489
info->implementation = "clock_gettime(CLOCK_REALTIME)";
1490-
info->is_monotonic = 0;
1491-
info->is_adjusted = 1;
1490+
info->monotonic = 0;
1491+
info->adjusted = 1;
14921492
if (clock_getres(CLOCK_REALTIME, &res) == 0)
14931493
info->resolution = res.tv_sec + res.tv_nsec * 1e-9;
14941494
else

Python/pytime.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info)
4040
BOOL isTimeAdjustmentDisabled;
4141

4242
info->implementation = "GetSystemTimeAsFileTime()";
43-
info->is_monotonic = 0;
43+
info->monotonic = 0;
4444
(void) GetSystemTimeAdjustment(&timeAdjustment, &timeIncrement,
4545
&isTimeAdjustmentDisabled);
4646
info->resolution = timeIncrement * 1e-7;
4747
if (isTimeAdjustmentDisabled)
48-
info->is_adjusted = 0;
48+
info->adjusted = 0;
4949
else
50-
info->is_adjusted = 1;
50+
info->adjusted = 1;
5151
}
5252
#else
5353
/* There are three ways to get the time:
@@ -70,8 +70,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info)
7070
if (info) {
7171
info->implementation = "gettimeofday()";
7272
info->resolution = 1e-6;
73-
info->is_monotonic = 0;
74-
info->is_adjusted = 1;
73+
info->monotonic = 0;
74+
info->adjusted = 1;
7575
}
7676
return;
7777
}
@@ -86,8 +86,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info)
8686
if (info) {
8787
info->implementation = "ftime()";
8888
info->resolution = 1e-3;
89-
info->is_monotonic = 0;
90-
info->is_adjusted = 1;
89+
info->monotonic = 0;
90+
info->adjusted = 1;
9191
}
9292
}
9393
#else /* !HAVE_FTIME */
@@ -96,8 +96,8 @@ pygettimeofday(_PyTime_timeval *tp, _Py_clock_info_t *info)
9696
if (info) {
9797
info->implementation = "time()";
9898
info->resolution = 1.0;
99-
info->is_monotonic = 0;
100-
info->is_adjusted = 1;
99+
info->monotonic = 0;
100+
info->adjusted = 1;
101101
}
102102
#endif /* !HAVE_FTIME */
103103

0 commit comments

Comments
 (0)