Skip to content

Commit

Permalink
Use pickle's loads/dumps as a faster deepcopy
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Bargull <[email protected]>
  • Loading branch information
mbargull committed Mar 26, 2024
1 parent a1d6f60 commit 78a023c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions conda_build/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import copy
import math
import os
import pickle
import re
import shutil
import time
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 78a023c

Please sign in to comment.