What happens when we compare list of integers in Python with inequalities?
Does it do an implicit sum()
?
>>> [1,1] > [1,1,1]
False
>>> sum([1,1]) > sum([1,1,1])
False
>>> [1,1,1] > [1,1,1]
False
>>> [1,1,1,1] > [1,1,1]
True
>>> sum([1,1,1,1]) > sum([1,1,1])
True
If so, which part of the CPython code does that?
It looks like it's not comparing len()
:
>>> pos, neg = [1,0], [0,0,0]
>>> pos > neg
True