In current pytest, the same expression is matched against all items. But it is re-parsed for every match. Add support for "compiling" an expression and reusing the result. Errors may only occur during compilation. This is done by parsing the expression into a Python `ast.Expression`, then `compile()`ing it into a code object. Evaluation is then done using `eval()`. Note: historically we used to use `eval` directly on the user input -- this is not the case here, the expression is entirely under our control according to our grammar, we just JIT-compile it to Python as a (completely safe) optimization.
4.5 KiB
4.5 KiB