gh-103793: Defer formatting task name by itamaro · Pull Request #103767 · python/cpython

bedevere-bot · GitHub

@itamaro

itamaro

changed the title gh-NNNNN: Defer formatting task namegh-103793: Defer formatting task name

Apr 24, 2023

Closed

gaogaotiantian
@itamaro

The default task name is "Task-<counter>" (if no name is passed in during Task creation). This is initialized in `Task.__init__` (C impl) using string formatting, which can be quite slow. Actually using the task name in real world code is not very common, so this is wasted init. Let's defer this string formatting to the first time the name is read (in `get_name` impl), so we don't need to pay the string formatting cost if the task name is never read.

@itamaro
@itamaro
@itamaro
@itamaro
@itamaro

itamaro

marked this pull request as ready for review

April 24, 2023 23:24

@itamaro
@ambv
@itamaro
@itamaro

…ng the next counter at lazy name generation

@itamaro

…on into defer-task-name-formatting

@itamaro
gvanrossum
kumaraditya303
@itamaro
@itamaro
@itamaro
@erlend-aasland
@bedevere-bot
@hugovk
@willingc
@itamaro

itamaro

deleted the defer-task-name-formatting branch

April 30, 2023 01:02

carljm

added a commit to carljm/cpython that referenced this pull request

May 1, 2023

Merged