from lzma import LZMAFile
import pickle as pickle
if fileName.endswith('.xz'):
    dataFile = LZMAFile(fileName, 'r')
else:
    dataFile = file(fileName, 'ro')
data = pickle.load(dataFile)
Сжатие данных в python/numpy