mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
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:
parent
10dd0f79bc
commit
e08cba191e
13
direct/src/dist/FreezeTool.py
vendored
13
direct/src/dist/FreezeTool.py
vendored
@ -2337,17 +2337,8 @@ class Freezer:
|
|||||||
return blob_offset
|
return blob_offset
|
||||||
|
|
||||||
def makeModuleDef(self, mangledName, code):
|
def makeModuleDef(self, mangledName, code):
|
||||||
result = ''
|
lines = ',\n '.join(','.join(map(str, code[i:i+16])) for i in range(0, len(code), 16))
|
||||||
result += 'static unsigned char %s[] = {' % (mangledName)
|
return f'static unsigned char {mangledName}[] = {{\n {lines}\n}};\n'
|
||||||
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
|
|
||||||
|
|
||||||
def makeModuleListEntry(self, mangledName, code, moduleName, module):
|
def makeModuleListEntry(self, mangledName, code, moduleName, module):
|
||||||
size = len(code)
|
size = len(code)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user