on-internet
← Community

Why object provides __reduce__ by default?

Stack Overflow ·

>>> class C(object): ... pass ... >>> c=C() >>> c.__reduce__ <built-in method __reduce__ of C object at 0x1ae734> Does this __reduce__ do anything if I don't implement it? Normally we add methods only when necessary, e.g. add __getitem__ to implement self[key], add __sub__ to implement x-y... So I guess it must do something by default? Otherwise it should be omitted..

Comments

Sign in or sign up to comment and upvote.

No comments yet.