== in python will stop comparing after the first character mismatch. You can use that fact to test byte by byte your password knowing that the more good characters you have, the longer the comparison will take, which is called a timing attack.
hmac.compare_digest is a constant time compare, in that no matter if there is a match or not, it will take the same amount of time.
hmac.compare_digest is a constant time compare, in that no matter if there is a match or not, it will take the same amount of time.