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.

classification
Title: Faster ElementTree deepcopying
Type: performance Stage: resolved
Components: Extension Modules Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: brett.cannon, python-dev, scoder, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-12-15 10:48 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
bench_etree_deepcopy.log serhiy.storchaka, 2015-12-15 10:48 Benchmark results
etree_deepcopy.patch serhiy.storchaka, 2015-12-15 11:21 review
etree_deepcopy2.patch serhiy.storchaka, 2015-12-15 14:15 review
Messages (3)
msg256455 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-15 10:48
According to lxml benchmark [1], deepcopying a tree in ElementTree is about 20 times slower than in lxml. Proposed patch optimizes deepcopying C implementation of ElementTree about 20 times. It is now 5% to 3 times faster than in lxml.

[1] http://lxml.de/performance.html
msg256459 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-12-15 14:15
Updated patch correctly handles rare cases when different elements share the same attrib dict and when the same Element is occurred on different places in ElementTree (that is no longer a tree, but a directed graph).
msg256796 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-12-21 10:57
New changeset 090c3e3a648d by Serhiy Storchaka in branch 'default':
Issue #25869: Optimized deepcopying ElementTree; it is now 20 times faster.
https://hg.python.org/cpython/rev/090c3e3a648d
History
Date User Action Args
2022-04-11 14:58:25adminsetgithub: 70057
2015-12-21 11:50:59serhiy.storchakasetstatus: open -> closed
assignee: serhiy.storchaka
resolution: fixed
stage: patch review -> resolved
2015-12-21 10:57:55python-devsetnosy: + python-dev
messages: + msg256796
2015-12-15 14:15:15serhiy.storchakasetfiles: + etree_deepcopy2.patch

messages: + msg256459
2015-12-15 11:21:51serhiy.storchakasetfiles: + etree_deepcopy.patch
2015-12-15 11:21:29serhiy.storchakasetfiles: - etree_deepcopy.patch
2015-12-15 10:48:42serhiy.storchakasetfiles: + bench_etree_deepcopy.log
2015-12-15 10:48:07serhiy.storchakacreate