This StackOverflow answer says python dicts keep insertion order of keys as of python 3.7. The comments to that answer discuss the implementation details of what happens when a key is deleted. I'd like to know: what does the language spec guarantee about key order in the face of deletes (preferably with a link)?
Based on the discussion, I bet it guarantees insertion order of the undeleted elements, but I've been unable to find confirmation.