Generate a Bitcoin Address and the Wif from a phrase Is there a way to speed up my Python code?

import scrypt
import binascii
from passlib.utils.pbkdf2 import get_prf, pbkdf2
from coinkit import BitcoinKeypair

def getWallet(phrase, saltPhrase):
    s1 = scrypt.hash(password=phrase+'\x01', salt=saltPhrase+'\x01', N=1&lt;&lt;18, r=8, p=1, buflen=32)
    s2 = pbkdf2(phrase+'\x02', saltPhrase+'\x02', 1&lt;&lt;16, keylen=32, prf='hmac-sha256')

    key = ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))
    key_hex = binascii.hexlify(key)
    newWallet = BitcoinKeypair(key_hex)
    return {"walletAddress":newWallet.address(), "walletWif":newWallet.wif_pk()}

myWallet = getWallet("ER8FT+HFjk0", "a@b.c")
print "Address: "+myWallet["walletAddress"]+"\nWif: "+myWallet["walletWif"]


To try it you need to install these libraries:

pip install scrypt passlib coinkit


This program generates a Bitcoin Address and the Wif from a phrase, but the problem is that it generates the Output in about 1 second, and that's too long. So i'm looking for a way to speed it up, and if there aren't any solutions, perhaps I could use another programming language?

Thank you.
If you're planning on running this repeatedly, you could try running this on PyPy, and see if the JIT starts to speed up some of the regions being run repeatedly.  That would be a low-effort way to try to get a performance improvement on long-running code.

Before doing any code changes, profile your current code.  That should tell you where the most gains are to be had.  Then you could move forward with optimizing with a lot more information.

And, it's possible that doing this in a language with a really good compiler for native machine code would get you faster results.  I would tend to think of OCaML in that context, but your milage may vary.