[issue33463] Can namedtuple._asdict return a regular dict instead of OrderedDict?

Serhiy Storchaka report at bugs.python.org
Tue May 15 01:26:08 EDT 2018


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

DeprecationWarning is for things that will be removed. This is a sign: don't use this feature, rewrite you code so that doesn't use it, otherwise it will be broken in future versions.

FutureVersion is for things that work now and will work in future, but will change its behavior in future. This is a sign: be prepared that your code will be broken in a way that will lead to returning a wrong result instead of failing. It is better to use alternatives until this feature be stabilized.

Both warnings are not well appropriate here. They are too loud, and there are no good alternatives to _asdict(). Most users don't care about additional methods or performance guaranties of the result, thy just need a mapping, and it is desirable if it preserves the order of named tuple fields. I think it would be better to not add a runtime warning. Instead you can add a warning in the documentation in previous versions (just to the versionchanged directive that says when _dict() started returning an OrderedDict).

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33463>
_______________________________________


More information about the Python-bugs-list mailing list