minor `close()` optimisation

This commit is contained in:
Casper da Costa-Luis 2021-02-25 16:25:05 +00:00
parent c76af4db65
commit 47e303cdee
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 4 additions and 3 deletions

View File

@ -1269,6 +1269,10 @@ class tqdm(Comparable):
pos = abs(self.pos)
self._decr_instances(self)
if self.last_print_t < self.start_t + self.delay:
# haven't ever displayed; nothing to clear
return
# GUI mode
if getattr(self, 'sp', None) is None:
return
@ -1287,9 +1291,6 @@ class tqdm(Comparable):
leave = pos == 0 if self.leave is None else self.leave
with self._lock:
if self.last_print_t < self.start_t + self.delay:
# haven't ever displayed; nothing to clear
return
if leave:
# stats for overall rate (no weighted average)
self._ema_dt = lambda: None