Skip to content

Commit 3239b29

Browse files
committed
Merge pull request #5498 from jreback/msgpack_perf
PERF: msgpack encoding changes to use to/from string for speed boosts
2 parents da07446 + 9bcdbd9 commit 3239b29

File tree

5 files changed

+215
-156
lines changed

5 files changed

+215
-156
lines changed

pandas/core/common.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,12 @@ def _asarray_tuplesafe(values, dtype=None):
18711871
else:
18721872
# Making a 1D array that safely contains tuples is a bit tricky
18731873
# in numpy, leading to the following
1874-
result = np.empty(len(values), dtype=object)
1875-
result[:] = values
1874+
try:
1875+
result = np.empty(len(values), dtype=object)
1876+
result[:] = values
1877+
except (ValueError):
1878+
# we have a list-of-list
1879+
result[:] = [ tuple(x) for x in values ]
18761880

18771881
return result
18781882

pandas/core/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ def to_msgpack(self, path_or_buf, **kwargs):
851851
852852
Parameters
853853
----------
854-
path : string File path
855-
args : an object or objects to serialize
854+
path : string File path, buffer-like, or None
855+
if None, return generated string
856856
append : boolean whether to append to an existing msgpack
857857
(default is False)
858858
compress : type of compressor (zlib or blosc), default to None (no compression)

0 commit comments

Comments
 (0)