-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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: broadcasting of unit LHS in string operations #12737
Conversation
I don't think we should automatically broadcast. That has implicit performance implications. I asserted the invariant in #12738 and ensure that the caller upholds it. |
|
Ah, right. In that case I think it is a nice feature, but I think it should be in a special broadcasting variant of Otherwise we will monomorphize both code variants where in many cases we only need one of the two. |
bec5d0e
to
8a3c32c
Compare
7b56f4a
to
ba498ba
Compare
c937dd9
to
2c94673
Compare
@nameexhaustion Why all the macros? |
Mainly to be able to apply a function to N inputs that are conditionally broadcasted using Although given that we currently only need to handle 2 inputs, I suppose it could also be a function instead. |
Rather than using an indirect implementation using |
Hmm - I could also just do Otherwise I don't know of any better way to do the broadcasting o.o |
@nameexhaustion As an example in pseudocode, for Note to self: at some point in the near future I want to do a pass over the function names in |
4d989f4
to
3274143
Compare
3177d8c
to
d7fcdf1
Compare
7a1d467
to
9d4a246
Compare
77881ef
to
35a5af0
Compare
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.
Sorry for being so picky 😅 But these functions could get used a lot so we should get them right.
V: PolarsDataType, | ||
F: FnMut(Option<T::Physical<'a>>) -> Result<Option<K>, E>, | ||
V::Array: ArrayFromIter<Option<K>>, | ||
{ |
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.
Same here.
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.
Just to confirm - this would mean requiring unary functions that take Option
- i.e. F: FnMut(Option<T::Physical<'a>>) -> Result<Option<K>, E>
to always behave as F(None) == None
- as otherwise the fast-path would be incorrect.
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.
Although, we could also cheaply elide this requirement by checking the output of F(input[0])
if input.len() == input.null_count()
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.
Hmm.. strictly speaking this would also require the function to be Fn
instead of FnMut
V::Array: for<'a> ArrayFromIter< | ||
<F as BinaryFnMut<Option<T::Physical<'a>>, Option<U::Physical<'a>>>>::Ret, | ||
>, | ||
{ |
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.
Unfortunately we can only do a fast-path here if both are full-null... Makes me wonder if this is a good idea after all :( We could still handle that wherever we call them though. Nevertheless, we should do a fast-path here for that case.
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.
To confirm - this would mean we require F: for<'a> BinaryFnMut<Option<T::Physical<'a>>, Option<U::Physical<'a>>>
to always behave as F(None, None) == None
dbd887f
to
f486834
Compare
@nameexhaustion Could you resolve the merge conflicts? Then this is ready to go I think. |
2d98dd5
to
26e109c
Compare
@orlp I've rebased |
Would fix #12632.