Reputation: 33252
import pickle
class A:
pass
pickle.dumps(B().__reduce__())
yields
(<function _reconstructor at 0x1010143b0>, (<class '__main__.B'>, <class 'object'>, None))
What is this function "_reconstructor". It's neither B
, B.__init__
, nor B.__new__
as I expected.
Upvotes: 0
Views: 3501
Reputation: 70715
I have to make 2 changes to get that result:
Change the name of your class from A
to B
.
Remove the outer pickle.dumps()
call.
In any case, pickle
is free to do anything it likes to reconstruct the object ;-) In this case, you can find the _reconstructor()
function in Lib/copyreg.py
.
Upvotes: 1