I want to understand how works the memory allocation in python when adding new data to a dictionary. In the code below, I was waiting that every new added data was stacked at the end, however it does not happen.
repetitions = {}
for item in new_deltas:
list_aux = []
if float(item[1]) <= 30:
if float(item[0]) in repetitions:
aux = repetitions[float(item[0])]
aux.append(item[1])
repetitions[float(item[0])] = aux
else:
list_aux.append(item[1])
repetitions[float(item[0])] = list_aux
print(repetitions)
The results I got are as below. Thus, I would like to understand why the new appended data is not added at the end of the stack, it is added in the middle of it.
My input data is:
new_deltas = [[1.452, 3.292182683944702], [1.449, 4.7438647747039795], [1.494, 6.192960977554321], [1.429, 7.686920166015625]]
The print line outputs:
{1.452: [3.292182683944702]}
{1.452: [3.292182683944702], 1.449: [4.7438647747039795]}
{1.452: [3.292182683944702], 1.494: [6.192960977554321], 1.449: [4.7438647747039795]}
{1.429: [7.686920166015625], 1.452: [3.292182683944702], 1.494: [6.192960977554321], 1.449: [4.7438647747039795]}