Skip to content

Commit 76b61ec

Browse files
committed
Optimization
1 parent c7b4def commit 76b61ec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crontools/crontab.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import dataclasses as dc
33
import datetime as dt
44
import heapq
5+
from math import ceil
56
import operator as op
67
import tzlocal
78
from typing import Any, ClassVar, Dict, Generic, Iterator, Iterable, Optional, Type, TypeVar, Tuple
@@ -141,8 +142,8 @@ def iter(self, start_from: Optional[int] = None) -> Iterator[int]:
141142
step = 1 if self.step is None else self.step
142143

143144
if start_from is not None:
144-
while begin < start_from:
145-
begin += step
145+
steps = ceil(max(start_from - begin, 0) / step)
146+
begin = begin + steps * step
146147

147148
return iter(range(begin, end + 1, step))
148149

0 commit comments

Comments
 (0)