On Tue, 10 Dec 2019 at 00:00, Steven D'Aprano <steve@pearwood.info> wrote:
On Sat, Dec 07, 2019 at 07:37:58PM +0000, Oscar Benjamin wrote:
I recently hit on a situation that created a one million line code file: https://github.com/pytest-dev/pytest/issues/4406#issuecomment-439629715
The original file (which is included in SymPy) has 3000 lines averaging 500 characters per line so that the total file is 1.5MB. Since it is a test file pytest rewrites the corresponding pyc file and adds extra lines to annotate the intermediate results in the large expressions. The pytest-rewritten code has just over a million lines.
If I'm reading you correctly, you're saying that, on average, pytest annotates each line of source code with over 300 additional lines of code.
To be clear that's what happens with this particular file but is not otherwise typical of pytest. The idea is to rewrite something like assert f(x+y) == z as tmp1 = x+y tmp2 = f(tmp1) tmp3 = z it tmp1 != tmp2: # Print information showing the intermediate expressions tmp1, tmp2, tmp3 This rewriting is normally useful and harmless but it explodes when used with complicated mathematical expressions like this: https://github.com/sympy/sympy/blob/d670689ae212c4f0ad4549eda17a111404694a27... -- Oscar