Add DateTime add/4 and shift_zone/3 UTC fast path - #15779
Merged
josevalim merged 2 commits intoAug 22, 2026
Conversation
Member
|
I agree with this but then we should:
|
reisub
marked this pull request as draft
August 21, 2026 21:01
DateTime.add/4 UTC fast pathDateTime add/4 and shift_zone/3 UTC fast path
Contributor
Author
Thanks, that makes sense. I've pushed a commit to add a new function head for This does marginally slow down You also mentioned |
reisub
marked this pull request as ready for review
August 22, 2026 05:47
Member
|
💚 💙 💜 💛 ❤️ |
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.
I ran into an issue where I was trying to call
DateTime.add()inside a mix task without the app started, which means without:tzdatastarted, and was surprised to see it fail on a UTCDateTime.The proposed change adds a fast path for UTC
DateTimes which avoids consulting the TZ database. It fixes this (admittedly niche!) issue.Etc/UTCdatetime, Apple M1 Max, Benchee averages (warmup: 1, time: 2, memory_time: 1)add/4withTzdata.TimeZoneDatabaseadd/4withCalendar.UTCOnlyTimeZoneDatabaseshift_zone/3to"Etc/UTC"withTzdata.TimeZoneDatabaseshift_zone/3to"Etc/UTC"withCalendar.UTCOnlyTimeZoneDatabaseshift/3²¹ Identical 167 ns medians; the average-level difference is outlier noise.
² Before = the removed dedicated
Etc/UTCclause, which never consulted the database — hence no per-database split and the small regression from the added iso_days round trip.Benchmark code
Raw results