Skip to content

Commit

Permalink
Only calculate start window timestamp once in BaseTimeWindowPartition…
Browse files Browse the repository at this point in the history
…sSubset.__contains__ (dagster-io#21792)

Summary:
speedscope suggests this might actually make a difference when there are
large numbers of time windows in the subset (for example, a */15 asset
or hourly asset going back to 2015)

Test Plan: BK

## Summary & Motivation

## How I Tested These Changes
  • Loading branch information
gibsondan committed May 13, 2024
1 parent dcdb781 commit e4109a9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1890,9 +1890,11 @@ def __contains__(self, partition_key: str) -> bool:
TimeWindowPartitionsDefinition, self.partitions_def
).time_window_for_partition_key(partition_key)

time_window_start_timestamp = time_window.start.timestamp()

return any(
time_window.start.timestamp() >= included_time_window.start.timestamp()
and time_window.start.timestamp() < included_time_window.end.timestamp()
time_window_start_timestamp >= included_time_window.start.timestamp()
and time_window_start_timestamp < included_time_window.end.timestamp()
for included_time_window in self.included_time_windows
)

Expand Down

0 comments on commit e4109a9

Please sign in to comment.