← 返回首页
RawJSON performance problem · Issue #169 · python-rapidjson/python-rapidjson · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

RawJSON performance problem #169

New issue
New issue

Description

Hello,

In serializejson , like you suggest in #100 , I heavily use RawJSON, in order to keep on the same line tuples or array of numerical values of the same type (single_line_array don't allow to treat differently array of same numerical types and others)
But RawJSON seems to have big performance problems .
Basicaly rapidjson.dumps should just copy string from RawJSON as it without any check for char needing escape or needing to be convert in ascii, but take 12x or 14x more time than a copy (20x if unicode chars) ! Do you have a idea why ? Moreover ensure_ascii True or False , should not have any performance differencies on RawJSON.

import rapidjson import copy @profile def test_RawJSON(): json =f'"[{"0,"*6000000}0]"' copie = json[:-1]+'"' # 3.6 msec rawjson = rapidjson.RawJSON(json) # 0.01 msec json_with_rawjson = rapidjson.dumps(rawjson, ensure_ascii=False) # 40 msec (12x time of a copy, for juste coping json !) json_with_rawjson_ascii = rapidjson.dumps(rawjson, ensure_ascii=True) # 50 msec (14x time of a copy, for juste coping json !) assert json == json_with_rawjson assert json == json_with_rawjson_ascii test_RawJSON()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.