Skip to content

Commit

Permalink
Drop Python 3.7 handling for pickle protocol 4 (#12857)
Browse files Browse the repository at this point in the history
Fixes #12851

Now that Python 3.8 is the minimum supported version, drop the special casing for Python 3.7's `HIGHEST_PROTOCOL`, which was 4 (not 5). In Python 3.8+, `HIGHEST_PROTOCOL >= 5`. So none of these branches are needed any more.

Authors:
  - https://github.com/jakirkham
  - GALI PREM SAGAR (https://github.com/galipremsagar)
  - Ashwin Srinath (https://github.com/shwina)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)
  - Bradley Dice (https://github.com/bdice)

URL: #12857
  • Loading branch information
jakirkham authored Mar 9, 2023
1 parent 9299c2b commit ea62e0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
17 changes: 8 additions & 9 deletions python/cudf/cudf/tests/test_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,14 @@ def check_packed_pickled_equality(df):
assert isinstance(sortvaldf.index, GenericIndex)
assert_packed_frame_picklable(sortvaldf)
# out-of-band
if pickle.HIGHEST_PROTOCOL >= 5:
buffers = []
serialbytes = pickle.dumps(
pack(df), protocol=5, buffer_callback=buffers.append
)
for b in buffers:
assert isinstance(b, pickle.PickleBuffer)
loaded = unpack(pickle.loads(serialbytes, buffers=buffers))
assert_eq(loaded, df)
buffers = []
serialbytes = pickle.dumps(
pack(df), protocol=5, buffer_callback=buffers.append
)
for b in buffers:
assert isinstance(b, pickle.PickleBuffer)
loaded = unpack(pickle.loads(serialbytes, buffers=buffers))
assert_eq(loaded, df)


def assert_packed_frame_picklable(df):
Expand Down
17 changes: 7 additions & 10 deletions python/cudf/cudf/tests/test_pickling.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2018-2022, NVIDIA CORPORATION.
# Copyright (c) 2018-2023, NVIDIA CORPORATION.

import pickle

Expand All @@ -25,15 +25,12 @@ def check_serialization(df):
assert isinstance(sortvaldf.index, (GenericIndex, RangeIndex))
assert_frame_picklable(sortvaldf)
# out-of-band
if pickle.HIGHEST_PROTOCOL >= 5:
buffers = []
serialbytes = pickle.dumps(
df, protocol=5, buffer_callback=buffers.append
)
for b in buffers:
assert isinstance(b, pickle.PickleBuffer)
loaded = pickle.loads(serialbytes, buffers=buffers)
assert_eq(loaded, df)
buffers = []
serialbytes = pickle.dumps(df, protocol=5, buffer_callback=buffers.append)
for b in buffers:
assert isinstance(b, pickle.PickleBuffer)
loaded = pickle.loads(serialbytes, buffers=buffers)
assert_eq(loaded, df)


def assert_frame_picklable(df):
Expand Down

0 comments on commit ea62e0e

Please sign in to comment.