title: python decimal comparison
body: <p>python decimal comparison</p>
  
  <pre><code>&gt;&gt;&gt; from decimal import Decimal
  &gt;&gt;&gt; Decimal('1.0') &gt; 2.0
  True
  </code></pre>
  
  <p>I was expecting it to convert 2.0 correctly, but after reading thru <a href="http://www.python.org/dev/peps/pep-0327" rel="noreferrer">PEP 327</a> I understand there were some reason for not implictly converting float to Decimal, but shouldn't in that case it should raise TypeError as it does in this case</p>
  
  <pre><code>&gt;&gt;&gt; Decimal('1.0') + 2.0
  Traceback (most recent call last):
    File "&lt;string&gt;", line 1, in &lt;string&gt;
  TypeError: unsupported operand type(s) for +: 'Decimal' and 'float'
  </code></pre>
  
  <p>so does all other operator / - % // etc</p>
  
  <p>so my questions are</p>
  
  <ol>
  <li>is this right behavior? (not to raise exception in cmp)</li>
  <li>What if I derive my own class and
  right a float converter basically
  Decimal(repr(float_value)), are
  there any caveats? my use case
  involves only comparison of prices</li>
  </ol>
  
  <p>System details: Python 2.5.2 on Ubuntu 8.04.1</p>