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

Consider using bytecode instead of AST #41

Open
almarklein opened this issue Jan 14, 2020 · 0 comments
Open

Consider using bytecode instead of AST #41

almarklein opened this issue Jan 14, 2020 · 0 comments

Comments

@almarklein
Copy link
Member

almarklein commented Jan 14, 2020

Currently, PScript parses the Python AST to generate JavaScript. It may be advantageous to use bytecode instead. Considerations:

  • Bytecode is also also available in frozen applications (currently, the source code must always be available in order to obtain the AST).
  • Bytecode is not standardized and changes per Python version (and implementation, e.g. Pypy). It's probably not too hard to keep up to date each version, and the AST suffers a similar fate except that its specified better.
  • With bytecode it's easier to trace the flow of the program, making type inference much easier, so it might work well for Make PyScript an optionally typed language #4
  • Bytecode is lower-level, and we'd mis out on a the higher level "structure" of the code that the AST provides. We'd have to do some research to see if this is a problem.
  • A change like this is so profound (and so much work) that it should probably just be a new project.
  • A change like this should probably be part of a larger initiative to make the language typed (with inference), and more predictable (maybe more Pythonic, but at the least far less JS surprises).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant