This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eltoder
Recipients Andrew.Lutomirski, belopolsky, eddygeek, eltoder, r.david.murray, serhiy.storchaka, yselivanov
Date 2016-05-15.16:23:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1463329405.79.0.357374754183.issue20371@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, this is similar to my second approach. (You need to copy via __reduce__, because __copy__ my have been overriden to return self.)

The general problem with it, is that if a subclass is designed to be immutable (probably a common case here), it may not handle changing of its attributes well. Attributes will be readonly, so you can't support replace(derived_attr=newval). And while you can change base class' attributes under the covers, doing so may break subclass invariants. E.g. it may have cached hashcode or another property derived from other attributes.

There's also a smaller problem of figuring attribute names for positional arguments of replace() to support derived attributes.
History
Date User Action Args
2016-05-15 16:23:25eltodersetrecipients: + eltoder, belopolsky, r.david.murray, serhiy.storchaka, yselivanov, Andrew.Lutomirski, eddygeek
2016-05-15 16:23:25eltodersetmessageid: <1463329405.79.0.357374754183.issue20371@psf.upfronthosting.co.za>
2016-05-15 16:23:25eltoderlinkissue20371 messages
2016-05-15 16:23:25eltodercreate