-
Notifications
You must be signed in to change notification settings - Fork 94
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
Convert several perl scripts to python #511
Conversation
The comments and python code were originally generated by AI based on the original asy-list.pl code; however, both were subsequently checked and modified by a human to improve both Python coding style and accuracy to the original script. The change was tested by comparing the output of `make asy-keywords.el` before and after the change. The resulting files are identical except for the comment naming the generating script, which was originally asy-list.pl but is now asy-list.py. Thus, the two output files differ by a single character.
Tested: I used a logging statement in the original `findsym.pl` to check that all of the files written by `findsym.pl` followed the pattern `*symbols.h`. I then checked that after the change, the resulting files differed from the originals by a single character (since the comment now cites `findsym.py` rather than `findsym.pl` as the source). The sole exception was `opsymbols.h`, which had no changes at all since it is generated by a different script.
Can you ensure the CI passes before merging this in? Also, could you check that the python scriptd and the old perl files produce the same output? Another thing - the shebang lines should be "python3", not "python" |
Here's a list of all the diffs of potentially generated files, comparing master versus the current branch. I should note that in addition to the
|
Also, just wondering, but is there a reason to use ascii encoding instead of UTF8? At least from my experience, I always use UTF-8 unless if there's a reason to use ASCII |
I was mainly concerned with fixing the lint errors. My reasoning, for the 30 seconds or so I spent thinking about this, was that if we have non-ascii characters in our C++ code (which is what these scripts are reading and writing, with the exception of Note that for scripts that read and write tex code or asy code (which can include tex code), I agree that utf8 is almost certainly preferred. |
Convert several perl scripts to python.
Python is now an installation dependency in any case, and the current asy developers are generally more familiar with python than with perl. Thus, converting the perl code to python should make it easier to maintain and improve these files.
Because I have noticed improvements being made to the perl scripts, I want to go ahead and get these merged even though I am still working on the most complex perl script,
runtime.pl
.The translations are based on AI-provided translations but thoroughly checked by me (with numerous modifications in the process). They could of course still contain bugs, but I am confident they are not worse than what I would produce if I tried to do this without the aid of AI.
For testing, I added a log statement to the original perl script to figure out exactly how it was being used during
make
, saved the results, and compared them to the results of the python generation. In all cases, the generated files differed by exactly one character, which was the name of the generating file (something.pl changed to something.py) in the comment block.Note: I have only tested the changes using the make utility. I do not know how to compile with cmake, although I have made an effort to change the cmake files as well.
Testing complication: At least on my machine, if I run a python file using perl, and it sees the python shebang line, it will call the python interpreter rather than interpreting the file as if it were perl. This could make it easy to miss if we're accidentally running python files with perl.