W
W
weranda2016-05-24 10:57:28
Python
weranda, 2016-05-24 10:57:28

Why do dictionary keys change their order, what is the algorithm?

Greetings
Dictionary and derivation of keys:

b = {
  'one': 'one',
  'two': 'two'
}
print(b.keys())

The result can be one, two or two, one . It is clear that a dictionary is an unordered set and you can stop there and not think about it, but you still want to understand. I do not understand the algorithm of this ordering or not ordering of dictionary elements. Some kind of algorithm must process the order of writing and outputting the elements of the dictionary and how it all happens at a deep level, what gears are spinning there and why exactly and not otherwise!?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Fedoryan, 2016-05-24
@weranda

Master the depths of search engines first.
Dictionary Implementation in Python 2.7

R
rasswet, 2016-05-24
@rasswet

"словарь – неупорядоченное множество и можно на этом остановиться и не думать об этом" - да, тем более даже если вы постигнете то, как это сейчас устроено, не факт что в след версии это не поменяется. имхо, эти знание никак не применить на практике.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question