On Oct 22, 2019, at 17:47, Chris Angelico <ros...@gmail.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).

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4RNXFDYEHUA2ZVA2UGSQ5GHFNEQN5WI4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to