SOLUTION 1 GZ0-Mod:
arg_types = map(type, args) zipped_args = list(zip(*(a.items() if isinstance(a, dict) else a for a in args))) random.shuffle(zipped_args) return [cls(elements) for cls, elements in zip(arg_types, zip(*zipped_args))] ```
UPDATE: Ran a performance benchmark - results for iterations = 1e7, and a, b, c = tuple, list, dict of length 10, nested, respectively:
- #1: Solution 1 GZ0-Mod
-- 114.2 sec, 71.2% faster than slowest - #2: Solution 2
---------- 131.9 sec, 48.0% faster than slowest - #3: Solution 1
---------- 155.7 sec, 25.4% faster than slowest - #4: Gloweye's lambda
--- 160.5 sec, 21.7% faster than slowest - #5: RootTwo's functools
-- 195.3 sec
Note: these differences are negligible in practice - and if otherwise, timing variance is substantial, and all are about on par (per noted benchmark)