Author serhiy.storchaka
Recipients asvetlov, eli.bendersky, gphemsley, mdk, p-ganssle, r.david.murray, scoder, serhiy.storchaka, thatiparthy
Date 2019-04-17.06:50:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> As it stands, calling Element.__deepcopy__() will succeed with the C
> implementation and fail with the Python implementation.

You should not call it directly. Use copy.deepcopy().

> What is
> different about the C implementation that requires the definition of
> __deepcopy__() in the first place?

__deepcopy__() in the C implementation is merely optimization. It is less efficient to convert from the efficient internal representation of Element object to tuples and dicts and back.

> However, create_new_element()
> does not make a copy of the attrib dict that is passed in, meaning that
> the internal attrib dict of an Element instance is mutable by changing
> the dict that was passed in.

create_new_element() usually is called with a new copy of the attrib dict. Making yet one copy inside it is just a waste of time. If in some cases it is called with an externally referred dict, fix these cases by making a copy before calling create_new_element().
Date User Action Args
2019-04-17 06:50:17serhiy.storchakasetrecipients: + serhiy.storchaka, scoder, r.david.murray, eli.bendersky, asvetlov, thatiparthy, mdk, p-ganssle, gphemsley
2019-04-17 06:50:17serhiy.storchakasetmessageid: <>
2019-04-17 06:50:16serhiy.storchakalinkissue32424 messages
2019-04-17 06:50:16serhiy.storchakacreate