Repository navigation
fix cubic time of _make_unique_tzname in get_transitions - #2152
Open
shamsManna wants to merge 1 commit into
Open
shamsManna wants to merge 1 commit into
shamsManna wants to merge 1 commit into
Conversation
Timezone.get_transitions names a STANDARD or DAYLIGHT subcomponent without TZNAME after its TZID, DTSTART and offsets, and _make_unique_tzname appended "_1" until the name was unused. n equal subcomponents therefore built names of length 2n and took cubic time: with the pytz provider, Calendar.from_ical of a 363 KiB VTIMEZONE with 4000 such subcomponents took 22 s. Remember the next numeric suffix per name, so a repeated name gets _1, _2, ... in linear time (0.37 s). AI: Claude Opus 5.5 (claude-opus-5-5) via Claude Code. Prompt: find a security bug in icalendar, reproduce it, and write a minimal fix with a regression test and change log entry. Output: (this commit), reviewed by the author.
shamsManna
requested review from
angatha,
niccokunzmann and
stevepiercy
as code owners
November 19, 2026 05:55
Contributor
|
Thanks for the pull request, @shamsManna! A maintainer will review it shortly. |
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked issue
Description
Timezone.get_transitionsnames a STANDARD or DAYLIGHT subcomponent without TZNAME after its TZID, DTSTART and offsets, and_make_unique_tznamekept appending_1until the name was free, so n equal subcomponents build names of length 2n in cubic time. With the pytz provider this runs duringCalendar.from_icalfor any VTIMEZONE with an unknown TZID: 4000 such subcomponents (363 KiB) take 22 s to parse, 0.37 s with the fix, which remembers the next numeric suffix per name (EST_1,EST_2, ...) and resolves the TODO there. Different input from #2047, which only limits RRULE frequency.Checklist
Additional information
Timings for
Calendar.from_icalwithuse_pytz()and n equal subcomponents without TZNAME: 1000: 0.34 s -> 0.12 s, 2000: 1.7 s -> 0.20 s, 4000: 22 s -> 0.37 s, 8000: -> 0.73 s. Locally,test_issue_1445.pyandtest_rfc_6868.py(9 tests) fail on main as well; everything else passes.