-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat(math): add LegacyDecMut API. #18099
Conversation
import "math/big" | ||
|
||
// LegacyDecMut is a wrapper around big.Int with an unsafe and mutable API | ||
type LegacyDecMut big.Int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some problem with the approach is that it'd be now possible to create an overflowed dec by doing LegacyDecMut(overflowedBigInt)
.
Is this a problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the benchmarks, please ensure that each iteration has deterministic final results and if you need to turn off benchmarking for noisy operations, you can invoke b.StopTimer() then b.StartTimer() after to continue benchmarking. Please see my review and thank you @testinginprod
d := LegacyMustNewDecFromStr("123456789.123456789") | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
sink = d.NegMut() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current code will just change signs and the number of b.N will define the final results non-deterministically,
but we want every iteration to produce the exact same effect regardless of the number of b.N, let's do this instead.
for i := 0; i < b.N; i++ {
b.StopTimer()
d := LegacyMustNewDecFromStr("123456789.123456789")
b.StartTimer()
sink = d.NegMut()
}
Could you revert this PR here as well: #17803? |
As discussed on Slack, this will be rethought for math/v2 (ref #17750) |
Description
Closes: #18066
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change