From 87bceb8a5a722a526df9a9062f973faca087a09b Mon Sep 17 00:00:00 2001 From: Sasha Romijn Date: Wed, 19 Apr 2023 13:05:27 +0200 Subject: [PATCH] Fix #774 - Fix NRTM generator performance on PyPy (#777) Apparently, PyPy deals quite poorly when extending the same string many times, as the old code did. More details in #774 / #777. --- irrd/mirroring/nrtm_generator.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/irrd/mirroring/nrtm_generator.py b/irrd/mirroring/nrtm_generator.py index 3b18c1869..8809b8f76 100644 --- a/irrd/mirroring/nrtm_generator.py +++ b/irrd/mirroring/nrtm_generator.py @@ -79,18 +79,18 @@ def generate( .sources([source]) .serial_nrtm_range(serial_start_requested, serial_end_requested) ) - operations = list(database_handler.execute_query(q)) - output = f"%START Version: {version} {source} {serial_start_requested}-{serial_end_display}\n" + output = [f"%START Version: {version} {source} {serial_start_requested}-{serial_end_display}\n"] - for operation in operations: - output += "\n" + operation["operation"].value + for operation in database_handler.execute_query(q): + operation_str = operation["operation"].value if version == "3": - output += " " + str(operation["serial_nrtm"]) + operation_str += " " + str(operation["serial_nrtm"]) text = operation["object_text"] if remove_auth_hashes: text = remove_auth_hashes_func(text) - output += "\n\n" + text + operation_str += "\n\n" + text + output.append(operation_str) - output += f"\n%END {source}" - return output + output.append(f"%END {source}") + return "\n".join(output)