gh-119396: Optimize %S format of PyUnicode_FromFormat() by vstinner · Pull Request #119412 · python/cpython · GitHub
Skip to content

gh-119396: Optimize %S format of PyUnicode_FromFormat() - #119412

Closed
vstinner wants to merge 1 commit into
python:mainfrom
vstinner:optim_object_str
Closed

vstinner wants to merge 1 commit into
python:mainfrom
vstinner:optim_object_str

Conversation

@vstinner

@vstinner vstinner commented May 22, 2024

Copy link
Copy Markdown
Member

Add fast paths for str, int and float object types.

Benchmark on %S and %R formats:

+----------------+--------+----------------------+
| Benchmark      | ref    | change               |
+================+========+======================+
| str()          | 654 ns | 556 ns: 1.18x faster |
+----------------+--------+----------------------+
| repr()         | 722 ns | 627 ns: 1.15x faster |
+----------------+--------+----------------------+
| Geometric mean | (ref)  | 1.16x faster         |
+----------------+--------+----------------------+

Add fast paths for str, int and float object types.

Benchmark on %S and %R formats:

+----------------+--------+----------------------+
| Benchmark      | ref    | change               |
+================+========+======================+
| str()          | 654 ns | 556 ns: 1.18x faster |
+----------------+--------+----------------------+
| repr()         | 722 ns | 627 ns: 1.15x faster |
+----------------+--------+----------------------+
| Geometric mean | (ref)  | 1.16x faster         |
+----------------+--------+----------------------+
@vstinner

Copy link
Copy Markdown
Member Author

@vstinner

Copy link
Copy Markdown
Member Author

@vstinner vstinner closed this May 22, 2024
@vstinner
vstinner deleted the optim_object_str branch May 22, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant