Author eric.smith
Recipients NeilGirdhar, alexdelorenzo, eric.smith, levkivskyi, rhettinger
Date 2018-08-10.20:53:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1533934394.84.0.56676864532.issue34363@psf.upfronthosting.co.za>
In-reply-to
Content
For the record, I don't disagree with namedtuples not having a base class.

Maybe it's best to let copy.deepcopy() deal with namedtuples, instead of trying to detect them here. So just special case exact tuples and lists, and pass everything else to copy.deepcopy().

>>> C = namedtuple('C', 'a b c')
>>> c = C(1, 2, 3)
>>> b=copy.deepcopy(c)
>>> b
C(a=1, b=2, c=3)
>>> hasattr(b, '_fields')
True
>>> hasattr(c, '_fields')
True
>>> b is c
False
>>>

Although by doing that, you lose dict_factory or tuple_factory on nested data structures, and namedtuples that contain dataclasses would be handled differently, I think. I'll do some investigating.
History
Date User Action Args
2018-08-10 20:53:14eric.smithsetrecipients: + eric.smith, rhettinger, NeilGirdhar, levkivskyi, alexdelorenzo
2018-08-10 20:53:14eric.smithsetmessageid: <1533934394.84.0.56676864532.issue34363@psf.upfronthosting.co.za>
2018-08-10 20:53:14eric.smithlinkissue34363 messages
2018-08-10 20:53:14eric.smithcreate