Advanced
Python
Q98 / 101
What is Python's __reduce__ method used for?
Correct! Well done.
Incorrect.
The correct answer is B) Customizing how an object is serialized by pickle — returning a callable and args to reconstruct the object
B
Correct Answer
Customizing how an object is serialized by pickle — returning a callable and args to reconstruct the object
Explanation
__reduce__ returns (callable, args) tuple. pickle calls callable(*args) to reconstruct. __reduce_ex__ takes a protocol version. Useful for customizing pickling of C extension types.
Progress
98/101