Fast way to split an int into bytes
<p>If I have an int that fits into 32 bits, what is the fastest way to split it up into four 8-bit values in python? My simple timing test suggests that bit masking and shifting is moderately faster than <code>divmod()</code>, but I'm pretty sure I haven't thought of everything.</p>

<pre><code>&gt;&gt;&gt; timeit.timeit("x=15774114513484005952; y1, x =divmod(x, 256);y2,x = divmod(x, 256); y3, y4 = divmod(x, 256)")
0.5113952939864248
&gt;&gt;&gt; timeit.timeit("x=15774114513484005952; y1=x&amp;255; x &gt;&gt;= 8;y2=x&amp;255; x&gt;&gt;=8; y3=x&amp;255; y4= x&gt;&gt;8")
0.41230630996869877
</code></pre>

<p>Before you ask: this operation will be used a lot. I'm using python 3.4. </p>