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

improve json decoding performance #51700

Closed
pitrou opened this issue Dec 7, 2009 · 11 comments
Closed

improve json decoding performance #51700

pitrou opened this issue Dec 7, 2009 · 11 comments
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir

Comments

@pitrou
Copy link
Member

pitrou commented Dec 7, 2009

BPO 7451
Nosy @rhettinger, @etrepum, @pitrou, @benjaminp
Files
  • json-opts2.patch
  • json-opts3.patch
  • json-opts4.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 = None
    closed_at = <Date 2010-09-04.20:17:11.093>
    created_at = <Date 2009-12-07.23:08:18.891>
    labels = ['library', 'performance']
    title = 'improve json decoding performance'
    updated_at = <Date 2010-09-04.20:17:11.091>
    user = 'https://github.com/pitrou'

    bugs.python.org fields:

    activity = <Date 2010-09-04.20:17:11.091>
    actor = 'pitrou'
    assignee = 'none'
    closed = True
    closed_date = <Date 2010-09-04.20:17:11.093>
    closer = 'pitrou'
    components = ['Library (Lib)']
    creation = <Date 2009-12-07.23:08:18.891>
    creator = 'pitrou'
    dependencies = []
    files = ['15478', '15484', '18755']
    hgrepos = []
    issue_num = 7451
    keywords = ['patch']
    message_count = 11.0
    messages = ['96082', '96093', '96097', '96098', '96099', '96169', '96171', '96903', '96908', '115611', '115612']
    nosy_count = 5.0
    nosy_names = ['rhettinger', 'bob.ippolito', 'pitrou', 'benjamin.peterson', 'vkuznet']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue7451'
    versions = ['Python 3.2']

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 7, 2009

    This patch does two things:

    • it speeds up decoding of JSON objects by doing fewer temporary allocations
    • it reduces memory use of decoded JSON objects by reusing key strings
      when they appear several times in a JSON string

    @pitrou pitrou added stdlib Python modules in the Lib dir performance Performance or resource usage labels Dec 7, 2009
    @benjaminp
    Copy link
    Contributor

    benjaminp commented Dec 8, 2009

    The problem with this is that it makes json in Python diverge even more
    from the simplejson trunk.

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 8, 2009

    Unless Bob applies it to simplejson as well, that is.

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 8, 2009

    I've just noticed that there is a persistent decoder instance in
    json._default_decoder. To avoid keeping references to past keys
    forever, this updated patch clears the memo dict when a string has
    finished decoding.

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 8, 2009

    Here is the patch.

    @vkuznet
    Copy link
    Mannequin

    vkuznet mannequin commented Dec 9, 2009

    I wonder if you can make a patch for 2.6 python branch.

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 9, 2009

    I wonder if you can make a patch for 2.6 python branch.

    No, 2.6 doesn't have the same C accelerator in the first place.

    @etrepum
    Copy link
    Mannequin

    etrepum mannequin commented Dec 27, 2009

    I applied most of this patch to r206 of simplejson trunk

    @pitrou
    Copy link
    Member Author

    pitrou commented Dec 27, 2009

    Le dimanche 27 décembre 2009 à 11:10 +0000, Bob Ippolito a écrit :

    Bob Ippolito <bob@redivi.com> added the comment:

    I applied most of this patch to r206 of simplejson trunk

    Thank you. Will you port it to CPython yourself or would you prefer
    someone else to do it?

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 4, 2010

    Updated patch against py3k.

    @pitrou
    Copy link
    Member Author

    pitrou commented Sep 4, 2010

    Committed in r84505.

    @pitrou pitrou closed this as completed Sep 4, 2010
    @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
    performance Performance or resource usage stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants