-
Notifications
You must be signed in to change notification settings - Fork 513
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
Remove eval when possible #2329
Comments
The number of After some days of hard work, almost all tests of the built-in test suite pass. Unfortunately, even without any |
If you want you can send me an HTML page using the standard parser and I can try to profile it. It'd be easier to profile if the parsing is launched after clicking on a button, takes 10s+ and prints something when execution is over. |
You can test the standard parser by adding these scripts in the HTML page <script type="text/javascript" src="/src/string_parser.js"></script>
<script type="text/javascript" src="/src/number_parser.js"></script>
<script type="text/javascript" src="/src/action_helpers.js"></script>
<script type="text/javascript" src="/src/python_parser.js"></script>
<script type="text/javascript" src="/src/full_grammar.js"></script> and set a
All the programs in <script type="text/python">, and the modules they import, will be parsed by the PEG parser in You can compare the parsing time between the 2 implementations, I didn't make performance tests but when running the built-in test suite it is obvious that it's still significantly slower, even without It's a shame really because it would make the implementation much easier to maintain, and more compliant with standard Python... |
Will it also work if I use the I'll try to do a quick test tomorrow. |
@denis-migdal I did some profiling of the standard parser and wrote about it here: #2354. I thought you might find it interesting! |
Eval is very very slow, as JS parser has to be invoked. Moreover, contrary to
new Function()
, it prevents some optimizations (3x slower).The list of all
eval
to check :var ${klass_name} = new $B.ast.${klass_name}()
)The list of all
new Function
to check :No ways around it : function is dynamically created, and would requires parsing.
\nreturn locals
)()__${ops[op]}__
] = Function('self', 'other', body)__${$B.$comps[op]}__
] = Function('self', 'other', body)__${comps[op]}__
] = Function('_self', 'other',The text was updated successfully, but these errors were encountered: