[Python-Dev] [RFC] Removing pure Python implementation of OrderedDict
INADA Naoki
songofacandy at gmail.com
Tue Sep 5 09:19:18 EDT 2017
On Tue, Sep 5, 2017 at 8:48 PM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> 05.09.17 11:38, INADA Naoki пише:
>>
>> ## Cons
>>
>> * All Python 3.7 implementations should provide _collections.OrderedDict
>> PyPy has it already. But I don't know about micropython.
>
>
> Current C implementation of OrderedDict is not safe regarding using mutating
> dict methods (or dict C API) like dict.__setitem__ or PyDict_SetItem. Using
> them can cause hangs or segfaults. See issue24726 and issue25410. I hope
> your implementation will solve these issues, but there may be others.
Thanks for sharing these issues.
My pull request is still early stage and may have some bugs.
But I think it will solve many of issues because most odd behaviors comes from
difficult of consistency between linked list and dict.
> While
> the C implementation still is not enough mature, we should allow users that
> encountered one of such issues to use pure Python implementation which is
> free from hangs and segfaults.
>
I see.
Maybe, we can move Pure Python OrderedDict to collections._odict module,
and collections/__init__.py can be like this:
from _collections import OrderedDict
# Pure Python implementation can be used when C implementation
cause segfault.
# from collections._odict import OrderedDict
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/songofacandy%40gmail.com
More information about the Python-Dev
mailing list