[melbourne-pug] Data type assumptions in Python

Javier Candeira javier at candeira.com
Thu Sep 5 13:02:34 CEST 2013


On Thu, Sep 5, 2013 at 6:19 PM, William ML Leslie
<william.leslie.ttg at gmail.com> wrote:
> 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.

Good point, and great history lesson. However, that is a serious bug
in the implementation in the provided numeric types, not in the sorted
list implementation. Some expectations are reasonable.

J


More information about the melbourne-pug mailing list