d_list
на 100.000 у меня выполнилось за 0.6868....res = []
for dictionary in d_list: # * 100_000:
result_dict = {}
for key in dictionary:
if dictionary[key] is not None:
result_dict[key] = dictionary[key]
result_dict = {**result_dict, **{'qty1': False, 'fp1': False,
'qty2': False, 'fp2': False,
'qty3': False, 'fp3': False}}
if isinstance(dictionary['b'], list):
for z in range(1, len(dictionary['b']) - 1):
result_dict[f'qty{z}'] = dictionary['b'][z - 1]['qty']
result_dict[f'fp{z}'] = dictionary['b'][z - 1]['fp']
res.append(result_dict)
b
в исходном виде.res = []
for dictionary in d_list: # * 100_000:
result_dict = {'a': dictionary['a'],
'c': dictionary['c'],
'qty1': False, 'fp1': False,
'qty2': False, 'fp2': False,
'qty3': False, 'fp3': False
}
if isinstance(dictionary['b'], list):
for z in range(1, len(dictionary['b']) - 1):
result_dict[f'qty{z}'] = dictionary['b'][z - 1]['qty']
result_dict[f'fp{z}'] = dictionary['b'][z - 1]['fp']
res.append(result_dict)