tsoding / porth

It's like Forth but in Python
628 stars 50 forks source link

move assert out of loops #56

Closed drocha87 closed 2 years ago

drocha87 commented 2 years ago

This commit move some asserts out of loop, giving us some speed improvements in euler/problem04.porth.

Running the actual code (with asserts inside loops)

time ~/pypy3.7-v7.3.5-linux64/bin/pypy porth.py sim euler/problem04.porth
906609
~/pypy3.7-v7.3.5-linux64/bin/pypy porth.py sim euler/problem04.porth  2,54s user 0,03s system 99% cpu 2,593 total

Moving out the assert from loop

time ~/pypy3.7-v7.3.5-linux64/bin/pypy porth.py sim euler/problem04.porth
906609
~/pypy3.7-v7.3.5-linux64/bin/pypy porth.py sim euler/problem04.porth  2,33s user 0,02s system 99% cpu 2,372 total
drocha87 commented 2 years ago

I think this PR is very trivial fix, and as the code base is being refactored very fast, this fix will be fixed naturally.