I ask this question out of curiosity (in particular, understanding how python works under the hood).
I fully understand that the python object is dictunordered - you can add a bunch of elements and print some view dict, and the ordering of the elements in the view will not correspond to the order being entered.
However, I wonder why the order changes from one code execution to the next?
I have a really simple python script that prints dictto the console. The dict type looks like this (content is pretty inappropriate):
{
'hello': 'hi',
'goodbye': 'bye',
'hahaha': 'lol',
}
Printing on the console leads to the fact that the elements are not only printed in random order, but also printed in a different order each time the program starts . Here is my question: why is this so?
NOTE. The python code is inside the django project (but I do not use any django functions in this case - just mention it if it is anyway relevant).
source
share