Skip to content

Performance: CJK codec decoders pay a cross-module call per character #156537

Closed

Description

@brittanyrey

This issue is to document a minor change to optimize codec.decode(). The codec modules are shared extensions and the CJK OUTCHAR() macro was calling a standard lib implementation for _PyUnicodeWriter_WriteChar. This was causing unnecessary overhead crossing back and forth between the shared object and the exported function for each character write.

There already exists a _PyUnicodeWriter_WriteCharInline to avoid this issue. Swapping in the inlined call to reduce overhead for all codecs in the package.

PR is ready to attach to issue.

Linked PRs

Activity

  1. added a commit that references this issue on Aug 29, 2026
  2. added 4 commits that reference this issue on Aug 31, 2026
  3. added a commit that references this issue on Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirperformancePerformance or resource usagetype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions