title: Speed up Python script or find alternative?
body: <p>Here's my current script:</p>
  
  <pre><code>import argparse
  from pybitcointools import *
  
  parser = argparse.ArgumentParser()
  parser.add_argument('filename')
  args = parser.parse_args()
  
  with open(args.filename) as textfile:
      for line in textfile:
         priv = sha256(line.rstrip())
         wif_u = encode_privkey(priv, 'wif')
         wif_c = encode_privkey(priv, 'wif_compressed')
         addr_u = pubtoaddr(privtopub(priv))
         addr_c = pubtoaddr(compress(privtopub(priv)))
         print("%s,%s" % (addr_u, wif_u))
         print("%s,%s" % (addr_c, wif_c))
  </code></pre>
  
  <p>I run this script to convert 1000 lines into 2000 bitcoin brain wallets (1000 x 2 to include both compressed and uncompressed).  It takes 12.5 seconds to run.</p>
  
  <p>If I remove these lines, it goes down from 12.5 seconds to 0.2 seconds:</p>
  
  <pre><code>addr_u = pubtoaddr(privtopub(priv))
  addr_c = pubtoaddr(compress(privtopub(priv)))
  </code></pre>
  
  <p>But of course, I need the addresses, not just the private keys in WIF format.</p>
  
  <p>So here's the 3 things I'm trying to figure out:</p>
  
  <ol>
  <li><p>Why does address generation take so much longer than private key generation?</p></li>
  <li><p>Is there a way to speed up the existing Python script to run in less than a second?</p></li>
  <li><p>If not, does anyone know of a simple alternative that could do this faster?</p></li>
  </ol>
  
  <p>I don't mind using Python, Perl, C, whatever does the job and is the fastest.</p>