TL;DR - really, seriously, no kidding, don’t even think about relying on dictionary traverse order, because it may change even from seemingly unrelated code changes.
I believe the reason for the change is that if you add some lines, the bytecode for the module grows, and of course the strings "pdb" and "set_trace" (or "time" and "sleep") have to be added to the module's list of constants. Naturally, memory for the module has to be allocated before the module runs, so any further allocations are done somewhere else.
Another comment – in Python 3, dict ordering will be different in each execution of Python, even if the code doesn't change. You can get the behavior already for 2.6+ by setting PYTHONHASHSEED (see http://docs.python.org/2/using... -- it prevents some DOS attacks on web servers, for example.