File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -621,8 +621,9 @@ Two new events are added: :monitoring-event:`BRANCH_LEFT` and
621621time
622622---- 
623623
624- * Ensure that :func: `time.sleep(0) <time.sleep> ` does not degrade over time
625-   on non-Windows platforms.
624+ * Ensure that the duration of :func: `time.sleep(0) <time.sleep> ` is as small
625+   as possible on non-Windows platforms when :manpage: `clock_nanosleep(2)`
626+   or :manpage: `nanosleep(2)` are used to implement :func: `!time.sleep `.
626627  (Contributed by Bénédikt Tran in :gh: `125997 `.)
627628
628629
Original file line number Diff line number Diff line change @@ -2222,8 +2222,7 @@ pysleep(PyTime_t timeout)
22222222#else 
22232223    PyTime_t  timeout_100ns  =  _PyTime_As100Nanoseconds (timeout ,
22242224                                                      _PyTime_ROUND_CEILING );
2225-     // Maintain Windows Sleep() semantics for time.sleep(0) 
2226-     if  (timeout_100ns  ==  0 ) {
2225+     if  (timeout_100ns  ==  0 ) { // gh-125997 
22272226        return  pysleep_zero ();
22282227    }
22292228#endif 
@@ -2397,9 +2396,9 @@ pysleep(PyTime_t timeout)
23972396// 
23982397// Rationale 
23992398// --------- 
2400- // time.sleep(0) accumulates delays in  the generic implementation, but we can  
2401- // skip some calls to `PyTime_Monotonic()` and other checks when the timeout  
2402- // is zero . For details, see https://github.com/python/cpython/pull/128274. 
2399+ // time.sleep(0) is slower when using  the generic implementation, but we make  
2400+ // it faster than time.sleep(eps) for eps > 0 so to avoid some performance  
2401+ // annoyance . For details, see https://github.com/python/cpython/pull/128274. 
24032402static  int 
24042403pysleep_zero (void )
24052404{
@@ -2442,7 +2441,7 @@ pysleep_zero(void)
24422441    if  (PyErr_CheckSignals ()) {
24432442        return  -1 ;
24442443    }
2445- #else 
2444+ #else   // Windows implementation 
24462445    Py_BEGIN_ALLOW_THREADS 
24472446    // A value of zero causes the thread to relinquish the remainder of its 
24482447    // time slice to any other thread that is ready to run. If there are no 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments