Lee-W commented on code in PR #75847:
URL: https://github.com/apache/airflow/pull/75847#discussion_r4410775784


##########
airflow-core/src/airflow/timetables/_cron.py:
##########
@@ -153,6 +174,18 @@ def localize_partition_datetime(self, dt: 
datetime.datetime) -> DateTime:
         """
         return convert_to_utc(make_aware(dt.replace(tzinfo=None), 
self._timezone))
 
+    def _localized_ticks_within_limit(self, naive: datetime.datetime, *, 
before: bool) -> list[DateTime]:
+        """Localize every cron tick within ``_FOLD_DELTA_LIMIT`` on one side 
of ``naive``, ``naive`` included."""
+        nudge = datetime.timedelta(microseconds=1)
+        cron = croniter(self._expression, start_time=naive + nudge if before 
else naive - nudge)
+        step = cron.get_prev if before else cron.get_next
+        localized: list[DateTime] = []
+        tick = step(datetime.datetime)
+        while abs(tick - naive) <= _FOLD_DELTA_LIMIT:
+            localized += _localize_all_folds(tick, self._timezone)
+            tick = step(datetime.datetime)
+        return localized
+

Review Comment:
   The fold search now runs only when the current or the target wall-clock time 
is ambiguous or does not exist. back to about 44 µs per call against about 40 
µs on main on my machine
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to