Skip to content

Commit 1352c3c

Browse files
committed
Remove unneeded base64 encoding of pickled data.
1 parent d78d004 commit 1352c3c

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

sdks/python/apache_beam/internal/cloudpickle_pickler.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
# pytype: skip-file
2929

30-
import base64
3130
import bz2
3231
import io
3332
import logging
@@ -154,25 +153,18 @@ def dumps(
154153
# representation change, and can break streaming job update compatibility on
155154
# runners such as Dataflow.
156155
if use_zlib:
157-
c = zlib.compress(s, 9)
156+
return zlib.compress(s, 9)
158157
else:
159-
c = bz2.compress(s, compresslevel=9)
160-
del s # Free up some possibly large and no-longer-needed memory.
161-
162-
return base64.b64encode(c)
158+
return bz2.compress(s, compresslevel=9)
163159

164160

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

168-
c = base64.b64decode(encoded)
169-
170164
if use_zlib:
171-
s = zlib.decompress(c)
165+
s = zlib.decompress(encoded)
172166
else:
173-
s = bz2.decompress(c)
174-
175-
del c # Free up some possibly large and no-longer-needed memory.
167+
s = bz2.decompress(encoded)
176168

177169
with _pickle_lock:
178170
unpickled = cloudpickle.loads(s)

0 commit comments

Comments
 (0)