[Python-Dev] PyObject_RichCompareBool identity shortcut
Nick Coghlan
ncoghlan at gmail.com
Fri Apr 29 01:04:09 CEST 2011
On Fri, Apr 29, 2011 at 8:55 AM, Guido van Rossum <guido at python.org> wrote:
> Sorry, we'll have to make an exception for those of course. This will
> somewhat complicate the interpretation of well-behaved, because those
> are *not* well-behaved as far as containers go (both dict key lookup
> and list membership are affected) but it is not a bug -- however it is
> a bug to put these in containers and then use container comparisons on
> the container.
That's a point in favour of the status quo, though - with the burden
of enforcing reflexivity placed on the containers, types are free to
make use of rich comparisons to return more than just simple
True/False results.
I hadn't really thought about it that way before this discussion - it
is the identity checking behaviour of the builtin containers that lets
us sensibly handle cases like sets of NumPy arrays.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list