Ocarina of Time: reduce memory use by 64 MiB for each OoT world past the first

Ocarina of Time: limit parallel output to 2, to not waste memory that doesn't benefit speed
Ocarina of Time: remove swarm of os.chdir()
This commit is contained in:
Fabian Dill
2021-09-03 12:50:26 +02:00
parent 51c38fc628
commit 1b27fc495f
5 changed files with 145 additions and 146 deletions

View File

@@ -6,9 +6,11 @@ from functools import lru_cache
__version__ = Utils.__version__ + ' f.LUM'
def data_path(*args):
def data_path(*args):
return Utils.local_path('worlds', 'oot', 'data', *args)
@lru_cache(maxsize=13) # Cache Overworld.json and the 12 dungeons
def read_json(file_path):
json_string = ""
@@ -20,11 +22,9 @@ def read_json(file_path):
return json.loads(json_string)
except json.JSONDecodeError as error:
raise Exception("JSON parse error around text:\n" + \
json_string[error.pos-35:error.pos+35] + "\n" + \
json_string[error.pos - 35:error.pos + 35] + "\n" + \
" ^^\n")
def is_bundled():
return getattr(sys, 'frozen', False)
# From the pyinstaller Wiki: https://github.com/pyinstaller/pyinstaller/wiki/Recipe-subprocess
# Create a set of arguments which make a ``subprocess.Popen`` (and
@@ -60,16 +60,17 @@ def subprocess_args(include_stdout=True):
ret.update({'stdin': subprocess.PIPE,
'stderr': subprocess.PIPE,
'startupinfo': si,
'env': env })
'env': env})
return ret
def get_version_bytes(a):
version_bytes = [0x00, 0x00, 0x00]
if not a:
return version_bytes;
return version_bytes
sa = a.replace('v', '').replace(' ', '.').split('.')
for i in range(0,3):
for i in range(0, 3):
try:
version_byte = int(sa[i])
except ValueError:
@@ -78,6 +79,7 @@ def get_version_bytes(a):
return version_bytes
def compare_version(a, b):
if not a and not b:
return 0
@@ -89,7 +91,7 @@ def compare_version(a, b):
sa = get_version_bytes(a)
sb = get_version_bytes(b)
for i in range(0,3):
for i in range(0, 3):
if sa[i] > sb[i]:
return 1
if sa[i] < sb[i]: