-
Notifications
You must be signed in to change notification settings - Fork 1
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
Ensure DispatchedSet unique keys on construction #23
Conversation
Codecov Report
@@ Coverage Diff @@
## main #23 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 1 1
Lines 63 78 +15
=========================================
+ Hits 63 78 +15
Continue to review full report at Codecov.
|
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.
It seems like using unique_elems
in construction or getindex
has performance implication but wouldn't it be a one-time cost in the constructor and a cost every call if it's in getindex
?
Yes, unless it's repeatedly constructed.
I think the |
After experimenting, I'm going to leave things as they were but still introduce |
73d2b86
to
5fcc70a
Compare
After further experimentation, I think we can get back to basically no runtime overhead using generated functions 😬. |
5fcc70a
to
4992d15
Compare
|
4992d15
to
e00d5f0
Compare
e00d5f0
to
87a36fb
Compare
I'm not sure I have the best understanding, but, my mental model consists of three fundamental pieces:
|
I'm happy with these changes overall. |
bors r+ |
Build succeeded: |
This PR changes the behavior so that we error on the construction of
DispatchedSet
s, rather than throwing an error ongetindex(::DispatchedSet, key)
for non-unique keys. I think I prefer this behavior, erroring on construction.At first I tried using
unique_elems
, but this incurred runtime overhead. Then, I tried the generated functionelems_are_unique
, and that seems to keep things all at compile time 🚀!I think it's still useful for users to have
unique_elems
/unique_keys(dt::AbstractDispatchedTuple)
, in case they may want to convert aDispatchedTuple
into aDispatchedSet
. I'll avoid exporting for now so that we can bikeshed the name / design.