Why such a big difference between python and python 3?

In excercise "Count Negative Numbers in a Sorted Matrix" i use binary search, that is my code:

class Solution:
    def countNegatives(self, grid: List[List[int]]) -> int:
        def binary(nums):
            l,r = 0,len(nums) - 1
            while l<r:
                pivot = l + (r-l) // 2
                if nums[pivot] < 0:
                    r = pivot
                else:
                    l = pivot + 1
            return l
        x = 0
        for i in grid:
                if i[-1] < 0:
                    x += len(i) - binary(i)
        return x

When i set "Python" i got time 100 ms, but when I chose "Python3" i got 132ms.
Could someone explain to me why there is such a difference ?
Thank you for your help :) (and sorry for my bad english)

Comments (1)