这些字符串的熵值很小,因此我认为压缩它们会很好地解决问题。问题在于,我考虑的压缩库(如在Python - Compress Ascii String中讨论的那些)似乎单独压缩每个字符串(存储所有需要解压缩的信息)。常识表明,将整个字符串集合压缩成单个全局blob/dictionary,并使用某种短引用引用单个字符串,从空间上来说更加高效。
以下是一些(伪)代码以澄清这个想法:
class TestResult:
def __init__(self):
self._Id = None
....
self.__appLogList = []
return
....
def setAppLogList(self, currentAppLogList):
self.__appLogList = currentAppLogList
# what I want to do here instead is
# for each s in currentAppLogList
# add s to global compressed blob and
# store reference in __appLogList
def getAppLogList(self):
return self.__appLogList
self.__appLogList = currentAppLogList
# what I want to do here instead is
# currentAppLogList = []
# for each ref in __appLogList
# decompress ref into string s and add s to currentAppLogList
# return currentAppLogList
# for each test
# add new TestResult to result map
# setAppLogList
# for selected tests
# getAppLogList and access logs
使用现有的公开可用的Python库,是否可以实现这个功能?