title: Minimum bit length needed for a positive integer in Python
body: <pre><code>1 = 0b1 -&gt; 1
  5 = 0b101 -&gt; 3
  10 = 0b1010 -&gt; 4
  100 = 0b1100100 -&gt; 7
  1000 = 0b1111101000 -&gt; 10
  …
  </code></pre>
  
  <p>How can I get the bit length of an integer, i.e. the number of bits that are necessary to represent a positive integer in Python?</p>