mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	bpo-43407: Clarify comparisons of time.monotonic() et al results (GH-24757)
Previous wording implied that only the result of call N and N+1 could be meaningfully compared, whereas comparing call N and N+M is fine.
This commit is contained in:
		
							parent
							
								
									8e1b406275
								
							
						
					
					
						commit
						ff5f05934d
					
				
					 2 changed files with 8 additions and 4 deletions
				
			
		| 
						 | 
					@ -277,7 +277,7 @@ Functions
 | 
				
			||||||
   Return the value (in fractional seconds) of a monotonic clock, i.e. a clock
 | 
					   Return the value (in fractional seconds) of a monotonic clock, i.e. a clock
 | 
				
			||||||
   that cannot go backwards.  The clock is not affected by system clock updates.
 | 
					   that cannot go backwards.  The clock is not affected by system clock updates.
 | 
				
			||||||
   The reference point of the returned value is undefined, so that only the
 | 
					   The reference point of the returned value is undefined, so that only the
 | 
				
			||||||
   difference between the results of consecutive calls is valid.
 | 
					   difference between the results of two calls is valid.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Use :func:`monotonic_ns` to avoid the precision loss caused by the
 | 
					   Use :func:`monotonic_ns` to avoid the precision loss caused by the
 | 
				
			||||||
   :class:`float` type.
 | 
					   :class:`float` type.
 | 
				
			||||||
| 
						 | 
					@ -306,7 +306,7 @@ Functions
 | 
				
			||||||
   clock with the highest available resolution to measure a short duration.  It
 | 
					   clock with the highest available resolution to measure a short duration.  It
 | 
				
			||||||
   does include time elapsed during sleep and is system-wide.  The reference
 | 
					   does include time elapsed during sleep and is system-wide.  The reference
 | 
				
			||||||
   point of the returned value is undefined, so that only the difference between
 | 
					   point of the returned value is undefined, so that only the difference between
 | 
				
			||||||
   the results of consecutive calls is valid.
 | 
					   the results of two calls is valid.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Use :func:`perf_counter_ns` to avoid the precision loss caused by the
 | 
					   Use :func:`perf_counter_ns` to avoid the precision loss caused by the
 | 
				
			||||||
   :class:`float` type.
 | 
					   :class:`float` type.
 | 
				
			||||||
| 
						 | 
					@ -334,7 +334,7 @@ Functions
 | 
				
			||||||
   CPU time of the current process.  It does not include time elapsed during
 | 
					   CPU time of the current process.  It does not include time elapsed during
 | 
				
			||||||
   sleep.  It is process-wide by definition.  The reference point of the
 | 
					   sleep.  It is process-wide by definition.  The reference point of the
 | 
				
			||||||
   returned value is undefined, so that only the difference between the results
 | 
					   returned value is undefined, so that only the difference between the results
 | 
				
			||||||
   of consecutive calls is valid.
 | 
					   of two calls is valid.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Use :func:`process_time_ns` to avoid the precision loss caused by the
 | 
					   Use :func:`process_time_ns` to avoid the precision loss caused by the
 | 
				
			||||||
   :class:`float` type.
 | 
					   :class:`float` type.
 | 
				
			||||||
| 
						 | 
					@ -626,7 +626,7 @@ Functions
 | 
				
			||||||
   CPU time of the current thread.  It does not include time elapsed during
 | 
					   CPU time of the current thread.  It does not include time elapsed during
 | 
				
			||||||
   sleep.  It is thread-specific by definition.  The reference point of the
 | 
					   sleep.  It is thread-specific by definition.  The reference point of the
 | 
				
			||||||
   returned value is undefined, so that only the difference between the results
 | 
					   returned value is undefined, so that only the difference between the results
 | 
				
			||||||
   of consecutive calls in the same thread is valid.
 | 
					   of two calls in the same thread is valid.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Use :func:`thread_time_ns` to avoid the precision loss caused by the
 | 
					   Use :func:`thread_time_ns` to avoid the precision loss caused by the
 | 
				
			||||||
   :class:`float` type.
 | 
					   :class:`float` type.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,4 @@
 | 
				
			||||||
 | 
					Clarified that a result from :func:`time.monotonic`,
 | 
				
			||||||
 | 
					:func:`time.perf_counter`, :func:`time.process_time`, or
 | 
				
			||||||
 | 
					:func:`time.thread_time` can be compared with the result from any following
 | 
				
			||||||
 | 
					call to the same function - not just the next immediate call.
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue