Problem with OrderedDict

INADA Naoki songofacandy at gmail.com
Wed May 30 09:05:52 EDT 2018


> However, the error seems to be intermittent - there are times when it
should
> fail, but does not - so I want to investigate further.


CPython raise RuntimeError *by chance*.
Detecting all invalid usage will increase runtime cost.
So CPython may and may not raise RuntimeError.

> I tried to reduce it to a simple example. I succeeded, but there are two
> problems -

> 1. It always fails, so I have not reproduced the intermittent nature yet.

> 2. It gives a different error -

>      RuntimeError: dictionary changed size during iteration

> So my first question is, what is the difference between the two error
> messages?

2nd error will happen when internal hash table is rebuilt while iterating.
If you read C source code, you can expect when it happens.

-- 
INADA Naoki  <songofacandy at gmail.com>



More information about the Python-list mailing list