Skip to content

RawJSON performance problem #169

Open
@SmartAudioTools

Description

@SmartAudioTools

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions