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

compile symbolic code into Python code #6

Open
johnyf opened this issue Mar 15, 2017 · 1 comment
Open

compile symbolic code into Python code #6

johnyf opened this issue Mar 15, 2017 · 1 comment
Assignees
Labels
enhancement A new feature, an improvement, or other addition.

Comments

@johnyf
Copy link
Member

johnyf commented Mar 15, 2017

It is convenient to program symbolic code using mathematics (TLA+). Multi-line Python strings and str.format are excellent for this job. For development, this works well. For stable code deployment, it is slow. Calling the parser and bitblaster takes long time compared to lightweight to medium size BDD operations (that don't last minutes). The delay becomes especially noticeable for TLA+ expressions that appear inside tight loops, and profiling showed that it dominates runtime.

The manual approach that addresses this problem is to simply write code calling directly functions that operate on BDDs, instead of a TLA+ string. Automate this conversion, so that it never need to happen in user code. This can be done by compiling TLA+ to Python code objects and using a decorator to memoize them. A similar approach was used in tulip.spec.form.GRSpec.compile_init.

A more traditional approach would be to translate the Python module and replace such strings by the equivalent Python code, but it introduces an inconvenient extra step and requires syntactically recognizing the strings to replace, which isn't a clearly defined problem (it is implicit). The proposed approach is explicit, and easier to implement.

@johnyf johnyf added the enhancement A new feature, an improvement, or other addition. label Mar 15, 2017
@johnyf johnyf self-assigned this Apr 5, 2017
@johnyf
Copy link
Member Author

johnyf commented Oct 7, 2017

Similar idea to lambdify.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature, an improvement, or other addition.
Projects
None yet
Development

No branches or pull requests

1 participant