From 172134f4d7e4f3c24d40d7eb4dc6d596a070b71a Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Mon, 18 Mar 2024 15:09:43 +0100 Subject: [PATCH 1/4] Use strict equality for comparing properties We found that for really large tuples the Julia compiler would give up on constfolding the comparison leading to a runtime check. Tuples of symbols are `===` so this change makes it easier for the compiler to inline. --- src/ConstructionBase.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ConstructionBase.jl b/src/ConstructionBase.jl index 0be68fb..ff905a4 100644 --- a/src/ConstructionBase.jl +++ b/src/ConstructionBase.jl @@ -50,7 +50,7 @@ getproperties(o::Tuple) = o if VERSION >= v"1.7" function check_properties_are_fields(obj) - if propertynames(obj) != fieldnames(typeof(obj)) + if propertynames(obj) !== fieldnames(typeof(obj)) error(""" The function `Base.propertynames` was overloaded for type `$(typeof(obj))`. Please make sure `ConstructionBase.setproperties` is also overloaded for this type. From b25fef564b7ff7912cc646d0effe0489cd47936a Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Mon, 18 Mar 2024 15:26:28 +0100 Subject: [PATCH 2/4] add comment --- src/ConstructionBase.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ConstructionBase.jl b/src/ConstructionBase.jl index ff905a4..0b79c45 100644 --- a/src/ConstructionBase.jl +++ b/src/ConstructionBase.jl @@ -50,6 +50,7 @@ getproperties(o::Tuple) = o if VERSION >= v"1.7" function check_properties_are_fields(obj) + # triple equals makes it easier for the compiler to optimize, see #82 if propertynames(obj) !== fieldnames(typeof(obj)) error(""" The function `Base.propertynames` was overloaded for type `$(typeof(obj))`. From 8d35cb993b11d65cb46b15f9c46e6b7371c0c40e Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Mon, 18 Mar 2024 16:52:04 +0100 Subject: [PATCH 3/4] Version bump --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 2986670..6a9b1f6 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "ConstructionBase" uuid = "187b0558-2788-49d3-abe0-74a17ed4e7c9" authors = ["Takafumi Arakaki", "Rafael Schouten", "Jan Weidner"] -version = "1.5.4" +version = "1.5.5" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" From 53825d999af47c60e0a47a783843cfd36e13f9d3 Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Mon, 18 Mar 2024 21:05:47 +0100 Subject: [PATCH 4/4] Update src/ConstructionBase.jl Co-authored-by: Frames White --- src/ConstructionBase.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ConstructionBase.jl b/src/ConstructionBase.jl index 0b79c45..ee2f771 100644 --- a/src/ConstructionBase.jl +++ b/src/ConstructionBase.jl @@ -50,7 +50,8 @@ getproperties(o::Tuple) = o if VERSION >= v"1.7" function check_properties_are_fields(obj) - # triple equals makes it easier for the compiler to optimize, see #82 + # for ntuples of symbols `===` is semantically the same as `==` + # but triple equals is easier for the compiler to optimize, see #82 if propertynames(obj) !== fieldnames(typeof(obj)) error(""" The function `Base.propertynames` was overloaded for type `$(typeof(obj))`.