Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster ElementTree deepcopying #70057

Closed
serhiy-storchaka opened this issue Dec 15, 2015 · 3 comments
Closed

Faster ElementTree deepcopying #70057

serhiy-storchaka opened this issue Dec 15, 2015 · 3 comments
Assignees
Labels
extension-modules C modules in the Modules dir performance Performance or resource usage

Comments

@serhiy-storchaka
Copy link
Member

BPO 25869
Nosy @brettcannon, @scoder, @serhiy-storchaka
Files
  • bench_etree_deepcopy.log: Benchmark results
  • etree_deepcopy.patch
  • etree_deepcopy2.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2015-12-21.11:50:59.673>
    created_at = <Date 2015-12-15.10:48:06.969>
    labels = ['extension-modules', 'performance']
    title = 'Faster ElementTree deepcopying'
    updated_at = <Date 2015-12-21.11:50:59.672>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2015-12-21.11:50:59.672>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2015-12-21.11:50:59.673>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2015-12-15.10:48:06.969>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = ['41315', '41316', '41317']
    hgrepos = []
    issue_num = 25869
    keywords = ['patch']
    message_count = 3.0
    messages = ['256455', '256459', '256796']
    nosy_count = 4.0
    nosy_names = ['brett.cannon', 'scoder', 'python-dev', 'serhiy.storchaka']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue25869'
    versions = ['Python 3.6']

    @serhiy-storchaka
    Copy link
    Member Author

    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

    @serhiy-storchaka serhiy-storchaka added extension-modules C modules in the Modules dir performance Performance or resource usage labels Dec 15, 2015
    @serhiy-storchaka
    Copy link
    Member Author

    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).

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Dec 21, 2015

    New changeset 090c3e3a648d by Serhiy Storchaka in branch 'default':
    Issue bpo-25869: Optimized deepcopying ElementTree; it is now 20 times faster.
    https://hg.python.org/cpython/rev/090c3e3a648d

    @serhiy-storchaka serhiy-storchaka self-assigned this Dec 21, 2015
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant