-
Notifications
You must be signed in to change notification settings - Fork 948
Add pylibcudf.Scalar.to_py to avoid scalar conversion to host via pyarrow #19043
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
Conversation
if not self.is_valid(): | ||
return None | ||
elif self.type().id() == type_id.BOOL8: | ||
return (<numeric_scalar[cbool]*>self.c_obj.get()).value() |
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.
You could try storing these in variables self.type().id()
and self.c_obj.get()
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.
Sure thing, good idea!
@@ -168,6 +169,47 @@ cdef class Scalar: | |||
""" | |||
return _from_numpy(np_val) | |||
|
|||
def to_py(self): |
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.
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.
An old habit of mine before match
existed in Python. I wouldn't be opposed to use match
in the future
/merge |
Description
closes #18921
Additionally adds a
expr.Literal.astype
method to containLiteral
casting logic between 2DataTypes
. This casting logic before was usingpylibcudf
to cast between 2 scalars. I think this is an unnecessary operation to do on a GPU, so now this just performs the cast using Polars directly.Checklist