Rust in Python steps character by character over a fstring to create a mini-ast which makes me think cPython does the same but I haven’t been able to find where.
For the curious, my code base is at github under user devdave, project name rython4. The antispam filter won’t let me post more than two hrefs to a post so that’s why there isn’t a direct link.
NOTE the Python software foundation license txt file hasn’t been copied into the repository yet. Regardless, because I am almost directly translating from cPython’s code base to rust, it’s a PSF project.
I have the language reference open/pinned on my browser and unfortunately the lexical rules for fstrings is only a little helpful, the valuable discovery would be finding the C code that processes f"string" to something the PEG parser can consume.