FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

rrule: seek daily between queries near lower bound by mercury125 · Pull Request #1560 · dateutil/dateutil · GitHub

rrule: seek daily between queries near lower bound - #1560

Open
mercury125 wants to merge 4 commits into
dateutil:masterfrom
mercury125:fix-654-rrule-between-performance
Open

mercury125 wants to merge 4 commits into
dateutil:masterfrom
mercury125:fix-654-rrule-between-performance

Conversation

mercury125 commented Sep 2, 2026
edited
Loading

Copy link
Copy Markdown

Fixes #654.

Supersedes #1557.

Problem

For an uncached DAILY rule, between() starts iteration at DTSTART and discards every occurrence through the lower bound. The example in #654 therefore replays roughly twenty years of daily occurrences to return one month.

Implementation

  • Let uncached between() queries request an iterator positioned near the lower bound.
  • For DAILY rules without COUNT, seek to the preceding aligned interval instead of replaying from DTSTART.
  • Preserve the existing path for cached rules, subclasses, incompatible timezone-awareness, floating timezone objects, datetime boundaries, and unsupported recurrence shapes.
  • Cover distant starts, multi-day intervals, BYHOUR, timezone conversion, datetime limits, cache population, and subclass iteration.

Performance

Measured against current master on an AMD Ryzen 7 8845H under WSL2 with CPython 3.13.15. Each result is the median of 11 CPU-pinned timeit batches after 10 warm-up calls, using the reproducer from #654.

Version Time per between() call
Current master 8.05 ms
This change 49.0 us

This is approximately a 164x speedup for #654's 20-year, uncached DAILY workload. Both versions return the same 30 occurrences; reaching the query interval requires 7,337 iterator pulls on master and 33 with this change.

The benefit scales with the distance from DTSTART: a query starting roughly one month after DTSTART improved from 76.5 us to 45.7 us (1.68x). A query that cannot use the seek path remained effectively unchanged (38.05 us on master and 38.20 us with this change). These measurements are specific to the supported DAILY seek path, not a general rrule-wide speedup claim.

CI compatibility

The branch keeps two current test-suite compatibility fixes as separate commits:

  • normalize the timezone property test to its UTC-aware Hypothesis input domain;
  • materialize isoparser parameters as required by pytest 9.1.

Neither compatibility commit changes dateutil runtime behavior.

Validation

  • The rrule.between is quite slow #654 reproducer returns identical results before and after the change.
  • A 384-case differential matrix covering intervals, start hours, BYHOUR values, query distances, and inclusive/exclusive bounds had zero mismatches against the legacy path.
  • Key rrule, timezone-property, and isoparser tests passed on CPython 2.7, 3.7, 3.12 with pytest 9.1, and 3.14.
  • Python 3.13 install-state tox suite: 2041 passed, 47 skipped, 17 xfailed.
  • Latest IANA tz master suite: 2040 passed, 47 skipped, 17 xfailed.
  • Coverage: 88%.
  • Docs, linkcheck, pre-commit, Darker, wheel, and sdist checks passed.

Disclosure

This change was developed with Codex assistance.

mercury125 marked this pull request as ready for review September 2, 2026 03:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rrule.between is quite slow

1 participant


Back | FazBrowse Home | New Git URL