From dcb4acb79adfc927f9dafdffb0035a62c7238a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 24 Oct 2024 12:24:10 +0200 Subject: [PATCH] Sort items in code generated using fypp When doing package builds, the result would be not reproducible, with differences in a few files following the same pattern: MODULE list_callstackentry - USE timings_base_type, ONLY: callstack_entry_type, routine_stat_type, routine_report_type + USE timings_base_type, ONLY: routine_stat_type, callstack_entry_type, routine_report_type It seems that this comes from the use of a Python set to deduplicate items. The order of items in a set is not stable, it is based on the hashes, which are seeded randomly for each invocation of Python. While at it, do not create an unnecessary list and do not use '_' as a variable name. ('_' is used when the value is supposed to be ignored.) --- src/common/cp_array_utils.fypp | 2 +- src/common/list.fypp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/cp_array_utils.fypp b/src/common/cp_array_utils.fypp index 07cc2dab0c..5f18f43aa7 100644 --- a/src/common/cp_array_utils.fypp +++ b/src/common/cp_array_utils.fypp @@ -31,7 +31,7 @@ REAL(${el1}$) < REAL(${el2}$) .OR. (ABS(REAL(${el1}$)-REAL(${el2}$)) < epsilon(M #:def uselist(list_in) #! comma-separated list of unique entries of list_in - $: ", ".join(list(set([_ for _ in list_in if _]))) + $: ", ".join(sorted(set(x for x in list_in if x))) #:enddef #:endmute diff --git a/src/common/list.fypp b/src/common/list.fypp index 87274435bc..7f9c2695ed 100644 --- a/src/common/list.fypp +++ b/src/common/list.fypp @@ -16,7 +16,7 @@ #:def uselist(list_in) #! comma-separated list of unique entries of list_in - $: ", ".join(list(set(list_in))) + $: ", ".join(sorted(set(list_in))) #:enddef #:def uselist_listmethods(t)