-
Notifications
You must be signed in to change notification settings - Fork 0
Add a command-line flag and an environment variable to enable pegen #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For example, a question that arises is what exactly the difference between |
The first one is private and I think is used because a subset of the config is needed to initialize some parts first but I can ask Victor Stinner for it, for the other two you can read https://docs.python.org/3/c-api/init_config.html#init-python-config and https://docs.python.org/3/c-api/init_config.html#init-isolated-conf |
So, at this time invoking python with the |
I dropped Victor an email and he told me what the problem was. Turns out everything is documented here for anyone who might be interested: https://pythondev.readthedocs.io/pyconfig.html. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In |
We should run the test suite with the new parser or at least some selected files like |
We can do this maybe by exporting the environment variable in the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought of something. I realize this may invalidate most of the work here, but I'd like to point it out anyway (I apologize and should have thought of this before):
When we switch to making the new parser the default, would we just invert the meaning of the -p
flag and the PYTHONPEG
env var? That seems weird, because it would mean there'd be no safe way for early adopters to force the PEG parser on (or off). It would be nicer if we could instead have the flag syntax be -p old
and -p new
, where we'd just switch the default. For the env var maybe we could use PYTHONPARSER=old
and PYTHONPARSER=new
. Other flag values would be errors; other env var values would be ignored.
Also, do we want compile()
to use the new parser (if the flag is set)? I think so. Note that this will also affect ast.parse()
, since it just calls compile()
. That seems fine, but it means there would be no explicit way to call the old parser.
I think that makes sense. There are similar environment variables already like |
Hm, maybe we've been acting with too much caution. We'd have to change this in the PEP. @lysnikolaou what do you think? |
This is definitely true. There's only around 26 days between alpha6 and beta1. Many people won't really know about the change, let alone use and test it in these first 26 days. Then again, having something I'm certainly leaning on making pegen the default parser. I don't think it makes much of a difference. Also, it would certainly give me much more confidence, because it would force that the whole CPython test suite passes with pegen enabled (which it still doesn't) really early on, which I think is a good thing. |
Let's implement the new/old option. That also gives us a negotiating position -- if people think it's too soon for Python 3.9, we can propose to have it available but off by default in 3.9, and reconsider in 3.10. Also it seems that if the flag was on by default the test suite doesn't pass yet? We would need to fix that before turning it on by default (and the fix oughtn't be "run the test suite with the old parser" :-). That would be a separate PR I presume. |
It's going to be multiple PRs most probably. Starting with #32. |
This is still an open question. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two more.
I just discovered that interactive mode doesn't use the new parser yet even if you specify (Also, I noticed a few more PEP 7 violations -- basically you cannot have |
This is related to my comment above. |
How? Sorry for being dense. |
In order for interactive mode to use pegen, we need to have the same We can either implement a new C API function that accepts a |
We need to make a function taking a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's land this first and then deal with interactive mode.
This is certainly a WIP and in no way complete. I'm just opening a PR for feedback, for things I might have missed etc.
Closes #4 and closes #5.