【发布时间】:2021-07-13 03:54:32
【问题描述】:
我正在尝试了解 hash(itertools.count(x, y)) 背后的基本机制。
我不习惯深入研究 CPython 实现,但我注意到 itertoolsmodule.c 中的 static PyTypeObject count_type has 0 for tp_hash。
我假设这意味着它没有在 C 中实现hash。那么,它是如何得到处理的呢?是否有用于实现 __hash__ 的 C 绑定 itertools.count 的 Python 对象?
另一方面,幕后发生的事情
itertools.count(0, 5) != itertools.count(0, 5)
【问题讨论】:
标签: python python-3.x hash itertools