[Steven D'Aprano]
> 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?

Yes.  Py_SIZE() gets the actual size of the underlying list.

The methods for most builtin containers typically access the
underlying structure directly.  That makes them fast and allows
them to maintain their internal invariants.


Raymond

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to