-
Notifications
You must be signed in to change notification settings - Fork 5
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 type stability of clipping methods #74
Conversation
Should we do the same for |
One reason not to do this in That might actually be a problem here too? There is a hack to get the best of both by putting the types inside |
Hmm, that's a good point. How about this: struct Joint{T} <: GeoInterface.AbstractTrait
end
Joint(args...) = Joint{Union{typeof.(args)...}() and then you pass in a If better for general adoption we could even put this in GeoInterface. Edit: an interesting name might be |
@skygering do you have any thoughts on changing this argument from a type to a constructed object? |
Okay, so I originally had that. My only concern relates to @asinghvi17's comments in #66. In my opinion, this is more painful. However, I don't see it being that big of a problem given that we eventually will have default Basically, I don't love it, but if it improves performance, then I don't think it is that bad. Does it improve runtime given the type instability doesn't propagate? |
I like the name |
We could always convert a tuple input at the top level, and type info should propagate through that, so I don't see it being too large of a burden? It's also not that much different than typing |
I dont think |
Summary from Slack:
|
Co-authored-by: Anshul Singhvi <[email protected]>
Ok, this PR is now implementing |
@inline _booltype(x::Bool) = x ? _True() : _False() | ||
@inline _booltype(x::Union{_True,_False}) = x |
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.
Can we move these definitions to where the booltypes are now defined, and change the last type from Union
to BoolsAsTypes
?
I haven't tried this out yet, but did you notice a performance speedup? |
The same one as swapping to constructed traits, shown in the profile.
|
Co-authored-by: Anshul Singhvi <[email protected]>
Closes #73
Seems the problem is less complicated that we thought.
target
should be a constructed trait rather than a trait type mostly GeoInterfaces.jl does this too for the same reason.I can't see any problems with
tuples
, the red block is just array allocation.