Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Provide feedback

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

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fastpath for encoding unsorted dict to JSON #95385

Closed
Labels
3.12only security fixesperformancePerformance or resource usagetype-featureA feature request or enhancement
@aivarsk

Description

@aivarsk

JSON encoder can produce output sorted by key (json.dumps(sort_keys=True)) The default value forsort_keys isFalse. The code always creates a list of dictionary items, sorts them if needed, and then iterates through them.
However, if sorting is not requested we can usePyDict_Next to avoid allocating a list of tuples.

pyperformance on my machine before changes:

### json_dumps ###Mean +- std dev: 10.6 ms +- 0.1 ms

pyperformance after changes:

### json_dumps ###Mean +- std dev: 9.00 ms +- 0.08 ms

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesperformancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp