On Oct 22, 2019, at 17:47, Chris Angelico email@example.com wrote:
Currently, the CPython optimizer can recognize constructs like "if x in [1,2,3,4]" or "for x in [1,2,3,4]" and use a literal tuple instead of building a list. Recognizing the splitting of a string as another equivalent literal could be done the same way.
Whether it's worthwhile or not is another question, but if the performance penalty of the run-time splitting is a problem, that CAN be fixed even without new syntax.
This would be relatively easy to do in an AST-processing import hook. Then people could experiment with it and if someone finds real-life performance benefits, file a bug to add it to CPython (which should be a lot easier nowadays than it was a few versions ago).