Skip to content

Commit 9bbb696

Browse files
committed
Use BZ2 & LZMA wrappers for full pickle support
1 parent 7293a37 commit 9bbb696

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pandas/io/pickle.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,8 @@ def to_pickle(
101101
is_text=False,
102102
storage_options=storage_options,
103103
) as handles:
104-
if handles.compression["method"] in ("bz2", "xz") and protocol >= 5:
105-
# some weird TypeError GH#39002 with pickle 5: fallback to letting
106-
# pickle create the entire object and then write it to the buffer.
107-
# "zip" would also be here if pandas.io.common._BytesZipFile
108-
# wouldn't buffer write calls
109-
handles.handle.write(pickle.dumps(obj, protocol=protocol))
110-
else:
111-
# letting pickle write directly to the buffer is more memory-efficient
112-
pickle.dump(obj, handles.handle, protocol=protocol)
104+
# letting pickle write directly to the buffer is more memory-efficient
105+
pickle.dump(obj, handles.handle, protocol=protocol)
113106

114107

115108
@doc(

0 commit comments

Comments
 (0)