Skip to content
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

Remove unnecessary std::move's in pylibcudf #16983

Merged
merged 8 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions python/pylibcudf/pylibcudf/binaryop.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,27 @@ cpdef Column binary_operation(

if LeftBinaryOperand is Column and RightBinaryOperand is Column:
with nogil:
result = move(
cpp_binaryop.binary_operation(
lhs.view(),
rhs.view(),
op,
output_type.c_obj
)
result = cpp_binaryop.binary_operation(
lhs.view(),
rhs.view(),
op,
output_type.c_obj
)
elif LeftBinaryOperand is Column and RightBinaryOperand is Scalar:
with nogil:
result = move(
cpp_binaryop.binary_operation(
lhs.view(),
dereference(rhs.c_obj),
op,
output_type.c_obj
)
result = cpp_binaryop.binary_operation(
lhs.view(),
dereference(rhs.c_obj),
op,
output_type.c_obj
)
elif LeftBinaryOperand is Scalar and RightBinaryOperand is Column:
with nogil:
result = move(
cpp_binaryop.binary_operation(
dereference(lhs.c_obj),
rhs.view(),
op,
output_type.c_obj
)
result = cpp_binaryop.binary_operation(
dereference(lhs.c_obj),
rhs.view(),
op,
output_type.c_obj
)
else:
raise ValueError(f"Invalid arguments {lhs} and {rhs}")
Expand Down
8 changes: 4 additions & 4 deletions python/pylibcudf/pylibcudf/column.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ cdef class Column:

cdef size_type null_count = libcudf_col.get().null_count()

cdef column_contents contents = move(libcudf_col.get().release())
cdef column_contents contents = libcudf_col.get().release()

# Note that when converting to cudf Column objects we'll need to pull
# out the base object.
Expand Down Expand Up @@ -247,7 +247,7 @@ cdef class Column:
cdef const scalar* c_scalar = slr.get()
cdef unique_ptr[column] c_result
with nogil:
c_result = move(make_column_from_scalar(dereference(c_scalar), size))
c_result = make_column_from_scalar(dereference(c_scalar), size)
return Column.from_libcudf(move(c_result))

@staticmethod
Expand All @@ -269,7 +269,7 @@ cdef class Column:
cdef Scalar slr = Scalar.empty_like(like)
cdef unique_ptr[column] c_result
with nogil:
c_result = move(make_column_from_scalar(dereference(slr.get()), size))
c_result = make_column_from_scalar(dereference(slr.get()), size)
return Column.from_libcudf(move(c_result))

@staticmethod
Expand Down Expand Up @@ -373,7 +373,7 @@ cdef class Column:
"""Create a copy of the column."""
cdef unique_ptr[column] c_result
with nogil:
c_result = move(make_unique[column](self.view()))
c_result = make_unique[column](self.view())
return Column.from_libcudf(move(c_result))


Expand Down
4 changes: 1 addition & 3 deletions python/pylibcudf/pylibcudf/column_factories.pxd
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright (c) 2024, NVIDIA CORPORATION.
from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move
from pylibcudf.libcudf.types cimport mask_state, size_type
from pylibcudf.libcudf.types cimport mask_state

from .column cimport Column
from .types cimport DataType, size_type, type_id
Expand Down
68 changes: 23 additions & 45 deletions python/pylibcudf/pylibcudf/column_factories.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,17 @@ cpdef Column make_empty_column(MakeEmptyColumnOperand type_or_id):
if isinstance(type_or_id, TypeId):
id = type_or_id
with nogil:
result = move(
cpp_make_empty_column(
id
)
)
result = cpp_make_empty_column(id)
else:
raise TypeError(
"Must pass a TypeId or DataType"
)
elif MakeEmptyColumnOperand is DataType:
with nogil:
result = move(
cpp_make_empty_column(
type_or_id.c_obj
)
)
result = cpp_make_empty_column(type_or_id.c_obj)
elif MakeEmptyColumnOperand is type_id:
with nogil:
result = move(
cpp_make_empty_column(
type_or_id
)
)
result = cpp_make_empty_column(type_or_id)
else:
raise TypeError(
"Must pass a TypeId or DataType"
Expand Down Expand Up @@ -92,12 +80,10 @@ cpdef Column make_numeric_column(
else:
raise TypeError("Invalid mask argument")
with nogil:
result = move(
cpp_make_numeric_column(
type_.c_obj,
size,
state
)
result = cpp_make_numeric_column(
type_.c_obj,
size,
state
)

return Column.from_libcudf(move(result))
Expand All @@ -121,12 +107,10 @@ cpdef Column make_fixed_point_column(
else:
raise TypeError("Invalid mask argument")
with nogil:
result = move(
cpp_make_fixed_point_column(
type_.c_obj,
size,
state
)
result = cpp_make_fixed_point_column(
type_.c_obj,
size,
state
)

return Column.from_libcudf(move(result))
Expand All @@ -151,12 +135,10 @@ cpdef Column make_timestamp_column(
else:
raise TypeError("Invalid mask argument")
with nogil:
result = move(
cpp_make_timestamp_column(
type_.c_obj,
size,
state
)
result = cpp_make_timestamp_column(
type_.c_obj,
size,
state
)

return Column.from_libcudf(move(result))
Expand All @@ -181,12 +163,10 @@ cpdef Column make_duration_column(
else:
raise TypeError("Invalid mask argument")
with nogil:
result = move(
cpp_make_duration_column(
type_.c_obj,
size,
state
)
result = cpp_make_duration_column(
type_.c_obj,
size,
state
)

return Column.from_libcudf(move(result))
Expand All @@ -211,12 +191,10 @@ cpdef Column make_fixed_width_column(
else:
raise TypeError("Invalid mask argument")
with nogil:
result = move(
cpp_make_fixed_width_column(
type_.c_obj,
size,
state
)
result = cpp_make_fixed_width_column(
type_.c_obj,
size,
state
)

return Column.from_libcudf(move(result))
4 changes: 2 additions & 2 deletions python/pylibcudf/pylibcudf/concatenate.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ cpdef concatenate(list objects):
c_tables.push_back((<Table?>tbl).view())

with nogil:
c_tbl_result = move(cpp_concatenate.concatenate(c_tables))
c_tbl_result = cpp_concatenate.concatenate(c_tables)
return Table.from_libcudf(move(c_tbl_result))
elif isinstance(objects[0], Column):
for column in objects:
c_columns.push_back((<Column?>column).view())

with nogil:
c_col_result = move(cpp_concatenate.concatenate(c_columns))
c_col_result = cpp_concatenate.concatenate(c_columns)
return Column.from_libcudf(move(c_col_result))
else:
raise ValueError("input must be a list of Columns or Tables")
Loading
Loading