-
Notifications
You must be signed in to change notification settings - Fork 22
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
Fix Constructor performance by removing runtime cost of applicable
#35
Comments
This PR shows that it is indeed This one is the same as Curtis's: we just After reading @oxinabox's awesome blog post here: I think that's a good solution for this problem generally. But actually, in this case, i think we can get away with just removing I think that PR is probably how we should move forward! :) What do you think? |
As @KristofferC pointed out we can't really rely on Traits would be a good solution here but without native support in Julia I think a cleaner solution would be to make a Base PR which defines: typemax(::Type{BigInt}) = nothing
typemin(::Type{BigInt}) = nothing Having these methods would allow us to call |
Ah yeah i think that's probably right unfortunately..
Mmm yes i like that approach. That seems reasonable! And in the meantime, we could define those ourselves, in this package. Crazy question: is there anything wrong with a |
If we define these methods in FixedPointDecimals we'll have a method redefinition warning when/if they get merged into Base. I'd rather keep things the way they are in #30 and once they're merged in base we can add those methods here but with an appropriate |
The storage type used by julia> FixedDecimal{Int128,2}(1.234567)
FixedDecimal{Int128,2}(1.23) Having an unbounded type as the storage just allows you to make as high precision values if you want: julia> parse(FixedDecimal{BigInt,100}, "0." * "9"^100)
FixedDecimal{BigInt,100}(0.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999) |
Okay i think that makes sense. Thanks.
That said, then, I actually still think I prefer the traits based solution in #33 to #30. My specific concerns with the
I like that the traits solution adds a clear, and declarative interface for adding your custom type. I do agree that it's a bit verbose, but I think I've it a bit simpler by making the trait types simply |
@NHDaly on an unrelated note to the substance of your post itself, why did you close your PR #33? I prefer @omus's PR to base: https://github.com/JuliaLang/julia/pull/29815/files |
Yeah, i think the Base PR is good. I'm happy with how #30 turned out, so it's all fine. I didn't really like the
Hmm, I meant to reopen it, and i thought I did... I originally closed it because I was advocating for #34 instead. But after Kristoffer explained why it doesn't work, I meant to reopen it when i made the above post. I don't want to open a new one now, because i think i've made enough noise on this repo today (sorry about all that, btw), but here's the final version of the Traits changes I was proposing: But yeah, i'm happy with #30. Thanks again everyone! :) |
Looks like we'll be waiting for |
Sounds great. Thanks again Curtis! :) i'll close this for now. feel free to reopen if you were using it to track the future dependent change on |
So there's this problem, well described by @omus here:
#30
TLDR, constructing these is way slower than it needs to be. It should be the same speed as regular ints, but it isn't:
I opened and closed a bunch of PRs here so I could discuss other alternatives we might consider, but I currently think this one is best:
#34
The text was updated successfully, but these errors were encountered: