A big difference seems to be, that you open the file and then make multiple comparison.
In my code for grabbing a single character it opens the file, traverses through it to the right location, closes and returns the single character. So for a single comparison of two chars, I already open the file twice.
And because it doesn't stop at the end of the line, but at the end of the file, for each "line"comparison, the file gets opened like 400 times just to compare the first "line" to itself (which doesn't give you any relevant information). So this is how I achieve this massive overhead.
I did something. I reopened the file for every for loop etc and then check over the file once for every character (each check is apprx 0.25 seconds but it is checking for every character soooo.)
yet to see if it works (forgot to use a print for the return value)
❯ time python3 -c "import test; print(test.is_sequential('0.txt'));"
False
python3 -c "import test; print(test.is_sequential('0.txt'));" 377.00s user 110.56s system 98% cpu 8:12.75 total
❯ time python3 -c "import test; print(test.is_sequential('1.txt'));"
True
python3 -c "import test; print(test.is_sequential('1.txt'));" 364.06s user 106.60s system 98% cpu 7:55.65 total
It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/jso__, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
View all comments
Show parent comment
2
u/G4METIME Mar 25 '21
A big difference seems to be, that you open the file and then make multiple comparison.
In my code for grabbing a single character it opens the file, traverses through it to the right location, closes and returns the single character. So for a single comparison of two chars, I already open the file twice.
And because it doesn't stop at the end of the line, but at the end of the file, for each "line"comparison, the file gets opened like 400 times just to compare the first "line" to itself (which doesn't give you any relevant information). So this is how I achieve this massive overhead.