You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Disclaimer: I have yet to run my code in a production type setting, so don't have a good sense of if this is a real problem or not yet.
But thinking about (for comparison) the Java Pattern class, for regular expressions. By calling Pattern.compile, you ensure that you compile your pattern only once, even if you do many comparisons.
With this library if I were to call the same method with an Expression in it a thousand times with different numbers, I think I'd effectively be recompiling that expression a thousand times.
So my question is, do you think there might be an opportunity to "compile" expressions beforehand, to save effort from repeated calls and would it be worthwhile?
The eval() method could be called by compile. Later, when eval is called on the compiled Expression, the variables could simply be inserted into the appropriate locations, without reparsing the whole string.
The text was updated successfully, but these errors were encountered:
Hi, if you look into the eval() method, you will see that it is exactly behaving like you described.
If the pattern has been 'compiled' before (converted to a RPN list of tokens using the shunting yard algorithm), the existing RPN list will be used. You can then change the variable assignments and call eval() again, which will use the previously 'compiled' expression with a new result.
Disclaimer: I have yet to run my code in a production type setting, so don't have a good sense of if this is a real problem or not yet.
But thinking about (for comparison) the Java Pattern class, for regular expressions. By calling Pattern.compile, you ensure that you compile your pattern only once, even if you do many comparisons.
With this library if I were to call the same method with an Expression in it a thousand times with different numbers, I think I'd effectively be recompiling that expression a thousand times.
So my question is, do you think there might be an opportunity to "compile" expressions beforehand, to save effort from repeated calls and would it be worthwhile?
The eval() method could be called by compile. Later, when eval is called on the compiled Expression, the variables could simply be inserted into the appropriate locations, without reparsing the whole string.
The text was updated successfully, but these errors were encountered: