title: pow or ** for very large number in Python
body: <p>I am trying to calculate some <code>num1**num2</code> in Python. But the problem is that <code>num1</code> is <code>93192289535368032L</code> and <code>num2</code> is <code>84585482668812077L</code>, which are very large numbers. </p>
  
  <p>I tried several methods as follows: First, I tried to calculate it by using the <code>**</code> operator. But it took too much time (I waited about 2 hours, but I got no result).</p>
  
  <p>Second, I used <code>math.pow(num1, num2)</code>. But I got this:</p>
  
  <pre><code>Traceback (most recent call last):   File "&lt;pyshell#23&gt;", line 1, in &lt;module&gt;
      math.pow(84585482668812077L, 93192289535368032L)
  OverflowError: math range error
  </code></pre>
  
  <p>Finally, I used <code>numpy.power</code>:</p>
  
  <pre><code>numpy.power(84585482668812077, 93192289535368032)
  -9223372036854775808
  </code></pre>
  
  <p>As you see, it gave me minus.</p>
  
  <p>What I really want to do is <code>result = (num1**num2)</code> and then the <code>result % num3</code>. So, I need to calculate this power value efficiently. </p>
  
  <p>How can I do this?</p>