/usr/lib/python3/dist-packages/partd/python.py is in python3-partd 0.3.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | """
get/put functions that consume/produce Python lists using msgpack or pickle
to serialize.
First we try msgpack (it's faster). If that fails then we default to pickle.
"""
from __future__ import absolute_import
from .compatibility import pickle
try:
from pandas import msgpack
except ImportError:
try:
import msgpack
except ImportError:
msgpack = False
from .encode import Encode
from functools import partial
def dumps(x):
try:
return msgpack.packb(x, use_bin_type=True)
except:
return pickle.dumps(x, protocol=pickle.HIGHEST_PROTOCOL)
def loads(x):
try:
return msgpack.unpackb(x, encoding='utf8')
except:
return pickle.loads(x)
def concat(lists):
return sum(lists, [])
Python = partial(Encode, dumps, loads, concat)
|