Optimising a four-state data structure
<p>I am manipulating <em>many</em> instances of the same data structure which can have one of four states. Currently I implement the states using <code>True</code>/<code>False</code> pairs:</p>

<pre><code>(True, True)
(True, False)
(False, True)
(False, False)
</code></pre>

<p>With those data-structures I repeatedly apply two functions <code>f</code>, <code>g</code> where</p>

<pre><code>g((True, True)) = (True, False)
g((True, False)) = (True, True)
g((False, True)) = (False, False)
g((False, False)) = (False, True)
</code></pre>

<p>and</p>

<pre><code>f((True, True)) = (False, False)
f((True, False)) = (False, True)
f((False, True)) = (True, False)
f((False, False)) = (True, True)
</code></pre>

<p>Can I improve upon this data structure for those two functions? (I want to optimise for speed.)</p>
