[melbourne-pug] Data type assumptions in Python

William ML Leslie william.leslie.ttg at gmail.com
Thu Sep 5 10:19:00 CEST 2013


On 5 September 2013 17:07, Javier Candeira <javier at candeira.com> wrote:
> Just one thing. Comparability is transitive, so I don't have to test
> comparability of the new element with all existing elements. I only
> have to check whether it's comparable to the first or root item in the
> structure. So that test is O(1), not O(n).

Well, you hope that comparability is transitive.  In python 2, *order*
wasn't even transitive between the provided numeric types: both
decimal and float would order correctly with respect to int, but not
with respect to each other.

Maybe there's a bit of a flat spot in python teaching in that people
don't know how to use NotImplemented correctly.  On the other hand,
correctly used NotImplemented and __radd__ can't actually solve the
problem of two numeric types implemented in isolation.

-- 
William Leslie

Notice:
Likely much of this email is, by the nature of copyright, covered
under copyright law.  You absolutely may reproduce any part of it in
accordance with the copyright law of the nation you are reading this
in.  Any attempt to deny you those rights would be illegal without
prior contractual agreement.


More information about the melbourne-pug mailing list