[issue16076] xml.etree.ElementTree.Element and xml.etree.ElementTree.TreeBuilder are no longer pickleable
Daniel Shahaf
report at bugs.python.org
Wed Jan 2 00:11:48 CET 2013
Daniel Shahaf added the comment:
Eli Bendersky wrote on Tue, Jan 01, 2013 at 00:32:51 +0000:
> 1. Why did you choose to implement __reduce__ and not __getstate__?
Maybe I was simply imitating what some other extension module was doing ;)
By using __reduce__ with the type as first return value, the
__setstate__ code becomes simpler because it doesn't need to address
'tag' and 'attrib'. This consideration is somewhat moot now that the
unpickle-Python-pickled-Element's code path has to think about all
instance attributes, including those settable by the constructor.
> 2. A lot of code appears to be shared between
> element_setstate_from_attributes and the init method implementation,
> can it be refactored?
It seems there might be room for code reuse --- both functions set
tag,text,tail,attrib (but the unpickler sets the children too). I'll
look into that in the next iteration (once the class name and pickle
output format issues are settled).
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16076>
_______________________________________
More information about the Python-bugs-list
mailing list