Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Base.rationalize instead of defining new function Base.MathConstants.rationalize #56793

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

sostock
Copy link
Contributor

@sostock sostock commented Dec 10, 2024

#55886 accidentally created a new function Base.MathConstants.rationalize instead of extending Base.rationalize, which is the reason why Base.rationalize(Int, π) isn’t constant-folded in Julia 1.10 and 1.11:

julia> @btime rationalize(Int,π);
  1.837 ns (0 allocations: 0 bytes)      # v1.9: constant-folded
  88.416 μs (412 allocations: 15.00 KiB) # v1.10: not constant-folded

This PR fixes that. It should probably be backported to 1.10 and 1.11.

@nsajko nsajko added backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 embarrassing-bugfix Whoops! labels Dec 12, 2024
@inkydragon inkydragon force-pushed the rationalize_irrational_fix branch from 78d265e to 3f16b17 Compare December 19, 2024 06:21
@giordano giordano added merge me PR is reviewed. Merge when all tests are passing rationals The Rational type and values thereof labels Dec 19, 2024
@inkydragon inkydragon merged commit d3c26b7 into JuliaLang:master Dec 19, 2024
9 checks passed
@inkydragon inkydragon removed the merge me PR is reviewed. Merge when all tests are passing label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 1.10 Change should be backported to the 1.10 release backport 1.11 Change should be backported to release-1.11 embarrassing-bugfix Whoops! rationals The Rational type and values thereof
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants