__reduce__ 和 __reduce_ex__ 有什么区别?
我知道这些方法用于 pickling/unpickling,与 reduce 内置函数无关,但是这两个方法有什么区别,为什么我们需要两者?
I understand that these methods are for pickling/unpickling and have no relation to the reduce built-in function, but what's the difference between the 2 and why do we need both?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文档说
另一方面,
在紧握的手上,Guido 说这是可以清理的区域。
The docs say that
On the other hand,
On the gripping hand, Guido says that this is an area that could be cleaned up.
__reduce_ex__
是__reduce__
应该是但从未成为的。__reduce_ex__
的工作方式与__reduce__
类似,但通过了 pickle 协议。__reduce_ex__
is what__reduce__
should have been but never became.__reduce_ex__
works like__reduce__
but the pickle protocol is passed.