﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37082	Improved readability and minor performance of sanitize_strftime_format regex substitution	xMintTea		"The current implementation of `sanitize_strftime_format` uses an inline lambda with indexed groups (`r""%s%%0%s%s"" % (m[1], mapping[m[2]], m[2])`) and a compact regular expression. While correct, it is not immediately obvious what the replacement does and why the groups are referenced by index.

This patch replaces the lambda with a small helper function `_replace_specifier`, uses a named group `(?P<letter>...)` in the regex, enables `re.VERBOSE` for readability, and switches to an f-string for clarity.

**No behavioral changes** – the early exit condition and the mapping dictionary remain identical. Equivalence was verified on Windows by mocking the early exit and comparing outputs for a comprehensive set of format strings, including edge cases with escaped percent signs (`%%`). The regex match results were also confirmed to be the same.

Additionally, the use of an f-string and named group yields a ~12-13% performance improvement over the old `%`-formatting with `m[1]`/`m[2]` access (measured with timeit on 240,000 calls)."	Cleanup/optimization	closed	Core (Other)	6.0	Normal	wontfix	sanitize_strftime_format, regex, readability, performance	xMintTea	Unreviewed	0	0	0	0	0	0
