diff --git a/conda_build/config.py b/conda_build/config.py index 86fbe438d1..465058701f 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 @@ -820,9 +821,12 @@ def clean_pkgs(self): def copy(self) -> Config: 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, pickle.HIGHEST_PROTOCOL)) if hasattr(self, "variants"): - new.variants = copy.deepcopy(self.variants) + new.variants = pickle.loads( + pickle.dumps(self.variants, pickle.HIGHEST_PROTOCOL) + ) return new # context management - automatic cleanup if self.dirty or self.keep_old_work is not True diff --git a/news/5281-perf-deepcopy b/news/5281-perf-deepcopy new file mode 100644 index 0000000000..b445074ea1 --- /dev/null +++ b/news/5281-perf-deepcopy @@ -0,0 +1,3 @@ +### Enhancements + +* Increased performance by using pickle instead of deepcopy. (#5281) diff --git a/pyproject.toml b/pyproject.toml index 9bc5272e8c..2726b59495 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -129,6 +129,7 @@ filterwarnings = [ # ignore conda-index error "ignore::PendingDeprecationWarning:conda_index", "ignore::DeprecationWarning:conda_index", + "ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning", ] markers = [ "serial: execute test serially (to avoid race conditions)",