Skip to content
Closed
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
16 changes: 4 additions & 12 deletions sdks/python/apache_beam/internal/cloudpickle_pickler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

# pytype: skip-file

import base64
import bz2
import io
import logging
Expand Down Expand Up @@ -154,25 +153,18 @@ def dumps(
# representation change, and can break streaming job update compatibility on
# runners such as Dataflow.
if use_zlib:
c = zlib.compress(s, 9)
return zlib.compress(s, 9)
else:
c = bz2.compress(s, compresslevel=9)
del s # Free up some possibly large and no-longer-needed memory.

return base64.b64encode(c)
return bz2.compress(s, compresslevel=9)


def loads(encoded, enable_trace=True, use_zlib=False):
"""For internal use only; no backwards-compatibility guarantees."""

c = base64.b64decode(encoded)

if use_zlib:
s = zlib.decompress(c)
s = zlib.decompress(encoded)
else:
s = bz2.decompress(c)

del c # Free up some possibly large and no-longer-needed memory.
s = bz2.decompress(encoded)

with _pickle_lock:
unpickled = cloudpickle.loads(s)
Expand Down
Loading