If provided, at pickling time
__reduce__() will be called with no
arguments, and it must return either a
string or a tuple.
另一方面
It is sometimes useful to know the
protocol version when implementing
__reduce__. This can be done by
implementing a method named
__reduce_ex__ instead of
__reduce__. __reduce_ex__, when it
exists, is called in preference over
__reduce__ (you may still provide
__reduce__ for backwards
compatibility). The __reduce_ex__
method will be called with a single
integer argument, the protocol
version.
The docs说吧
另一方面
在紧握的手上,Guido says这是一个可以清理的区域。
__reduce_ex__
是__reduce__
本应但从未成为的。__reduce_ex__
的工作方式与__reduce__
类似,但pickle协议已通过。相关问题 更多 >
编程相关推荐