On 14 February 2014 20:02, Antoine Pitrou <solip...@pitrou.net> wrote: > On Fri, 14 Feb 2014 10:46:50 +0100 > Lennart Regebro <rege...@gmail.com> wrote: >> > >> > Sending this to python-dev as I'm wondering if this was considered when the >> > choice to have objects of different types raise a TypeError when ordered... >> > >> > So, the concrete I case I have is implementing stable ordering for the >> > python Range objects that psycopg2 uses. These have 3 attributes that can >> > either be None or, for sake of argument, a numeric value. >> > > [...] >> >> It was considered. It's not obvious where you want "None" to appear in >> your ordering, so you will have to implement this by yourself. I can't >> come up with anything obviously shorter. > > I have to agree with Lennart. The fact that SQL defines an order for > NULL and other values doesn't mean it's obvious or right in any way (I > never remember which way it goes).
SQL doesn't define an order for NULL, it's more like a "quiet NaN" - if either operand is NULL, the result is also NULL. (I ran into this recently, in the context of "NULL == value" and "NULL != value" both being effectively false). We could theoretically do something similar, but the NULL handling in SQL is a frequent source of bugs in filter definitions, so that really doesn't sound like a good idea. Cheers, Nick. -- Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com