Below are what I have generalized after lots of writting and testing Python code.
If your written code is difficult to test, it’s bad code, refactor it!
If your written code has serious performance issue, refactor it!
If the above two doesn’t apply, then your code has a better chance of being bug-free (No guarantee though) and performing well. It’s nice code, so have a cup of tea/coffee and relax.