Skip to content
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

checkSyntax function that doesn't write to a file #295

Open
Almenon opened this issue May 7, 2023 · 4 comments
Open

checkSyntax function that doesn't write to a file #295

Almenon opened this issue May 7, 2023 · 4 comments

Comments

@Almenon
Copy link
Collaborator

Almenon commented May 7, 2023

Is your feature request related to a problem? Please describe.
If I call checkSyntax very frequently I'm going be writing a ton of temp files. Would be nice to avoid that overhead and just feed in the string through stdin.

Describe the solution you'd like
checkSyntax using stdin

Describe alternatives you've considered
overhead might not be a big deal?

Additional context
Related to re-architecture work in Almenon/AREPL-vscode#439. I'd like to throw away pythonGuiLibraryIsPresent and just check syntax all the time. Less code needed and much less hacky because one doesn't have to list out each GUI library.

@Almenon
Copy link
Collaborator Author

Almenon commented Jun 24, 2023

I did a bit of performance analysis:

startTime=Date.now();PythonShell.checkSyntax('f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;').then(o=>{console.log(Date.now()-startTime)})

result stays around 120 ms

time python -c "compile('f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;f=1;f=2;f=3;f=4;f=5;f=6;f=7;', '','exec')";

result started at 100ms then went down to a consistent 20ms

 time cat tictactoe.py | python -c "from sys import stdin;i=''.join([l for l in stdin]);compile(i,'','exec')";

was also around 20ms

@Almenon
Copy link
Collaborator Author

Almenon commented Jun 24, 2023

Another reason this would be a good change is windows doesn't clear the temp directory by default, so temporary syntax-checked python files will keep on piling up forever.

@PlakxD
Copy link

PlakxD commented Sep 5, 2024

I would like to work on this issue, however I am new to contributing to Python Shell. Is there anywhere I can go to sign up for write access to non-master branches?

@Almenon
Copy link
Collaborator Author

Almenon commented Sep 8, 2024

@PlakxD I'm not the admin of this repo, so I can't give out write access, but you can fork the repo and then submit a PR.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants