Performance of list vs. set equality operations
steven at REMOVE.THIS.cybersource.com.au
Thu Apr 8 03:07:53 EDT 2010
On Wed, 07 Apr 2010 20:14:23 -0700, Raymond Hettinger wrote:
> [Raymond Hettinger]
>> > If the two collections have unequal sizes, then both ways immediately
>> > return unequal.
> [Steven D'Aprano]
>> Perhaps I'm misinterpreting what you are saying, but I can't confirm
>> that behaviour, at least not for subclasses of list:
> For doubters, see list_richcompare() in
So what happens in my example with a subclass that (falsely) reports a
different length even when the lists are the same?
I can guess that perhaps Py_SIZE does not call the subclass __len__
method, and therefore is not fooled by it lying. Is that the case?
More information about the Python-list