dist: Significant performance boost for pfreeze

This method seems to run very slow in some versions of Python, this runs much faster
This commit is contained in:
rdb 2023-02-22 21:54:53 +01:00
parent 10dd0f79bc
commit e08cba191e

View File

@ -2337,17 +2337,8 @@ class Freezer:
return blob_offset
def makeModuleDef(self, mangledName, code):
result = ''
result += 'static unsigned char %s[] = {' % (mangledName)
for i in range(0, len(code), 16):
result += '\n '
for c in code[i:i+16]:
if isinstance(c, int): # Python 3
result += ('%d,' % c)
else: # Python 2
result += ('%d,' % ord(c))
result += '\n};\n'
return result
lines = ',\n '.join(','.join(map(str, code[i:i+16])) for i in range(0, len(code), 16))
return f'static unsigned char {mangledName}[] = {{\n {lines}\n}};\n'
def makeModuleListEntry(self, mangledName, code, moduleName, module):
size = len(code)