PyODict_New 是否受 Python 3.6 支持?
is PyODict_New supported by Python 3.6?
我找不到它的 Python 文档,尽管它存在于 https://github.com/python/cpython/blob/3.6/Objects/odictobject.c
您引用的页面是 OrderedDict
class 的 C 实现。但是,如果您使用 Python 而不是 C 进行编程,那么您需要做的就是从 collections
库模块中导入 Python 实现:
from collections import OrderedDict
mydict = OrderedDict()
对于您想在 Python 程序中使用 C 实现,我感到有些困惑。
而且,在任何情况下,从 Python 3.6 开始,Python 中的正常 dict
s 也会保留输入顺序,这意味着现在几乎没有理由使用 OrderedDict
在新代码中。 Raymond Hettinger(撰写 OrderedDict
class)tweeted 于 2016 年 9 月 "OrderedDict is dead. Long live dicts that are ordered."
我找不到它的 Python 文档,尽管它存在于 https://github.com/python/cpython/blob/3.6/Objects/odictobject.c
您引用的页面是 OrderedDict
class 的 C 实现。但是,如果您使用 Python 而不是 C 进行编程,那么您需要做的就是从 collections
库模块中导入 Python 实现:
from collections import OrderedDict
mydict = OrderedDict()
对于您想在 Python 程序中使用 C 实现,我感到有些困惑。
而且,在任何情况下,从 Python 3.6 开始,Python 中的正常 dict
s 也会保留输入顺序,这意味着现在几乎没有理由使用 OrderedDict
在新代码中。 Raymond Hettinger(撰写 OrderedDict
class)tweeted 于 2016 年 9 月 "OrderedDict is dead. Long live dicts that are ordered."