From 78a023c0cce934957bd1f56cde8b6170c73702f9 Mon Sep 17 00:00:00 2001 From: Marcel Bargull Date: Tue, 27 Feb 2024 08:18:05 +0100 Subject: [PATCH] Use pickle's loads/dumps as a faster deepcopy Signed-off-by: Marcel Bargull --- conda_build/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conda_build/config.py b/conda_build/config.py index 6e6cc8e28c..062dd1a856 100644 --- a/conda_build/config.py +++ b/conda_build/config.py @@ -9,6 +9,7 @@ import copy import math import os +import pickle import re import shutil import time @@ -817,9 +818,10 @@ def clean_pkgs(self): def copy(self): new = copy.copy(self) - new.variant = copy.deepcopy(self.variant) + # Use picke.loads(pickle.dumps(...) as a faster copy.deepcopy alternative. + new.variant = pickle.loads(pickle.dumps(self.variant, -1)) if hasattr(self, "variants"): - new.variants = copy.deepcopy(self.variants) + new.variants = pickle.loads(pickle.dumps(self.variants, -1)) return new # context management - automatic cleanup if self.dirty or self.keep_old_work is not True