It's very slow. I optimised a little, but couldn't find many ways to improve. One way way was change the libraries imported: instead of
import binascii
binascii.hexlify(merkle_root).decode()
replaced with importing the specific function from the library and giving an assignation as below
from binascii import hexlify as h
h(merkle_root).decode()
Then do this for every function called from an imported library. Improvement was slight but noticable