Find median of two sorted arrays
Sorry for being late, but had no time to study your code until today.
The results are the same which AmirHossein presented before.

After you conditionally swap the input arrays:

    if m &gt; n:
        A, B, m, n = B, A, n, m


you have m &lt;= n, so

    half_len = (m + n + 1) // 2


(after the fix by AmirHossein) is not less than m. That makes

    j = half_len - i


greater than zero if i &lt; m, so j &gt; 0 and i &lt; m is redundant.

Of course half_len is also is not greater than n, so similary j &lt; n if i &gt; 0.

As for the complexity, the code bisects the A array in each iteration, so the complexity is actually \$\mathcal{O}(\log m)\$ where m is the length of A after the conditional swap, or \$\mathcal{O}(\log (\min(m,n)))\$ in terms of input values of m,n. And this can be bounded by \$\mathcal{O}(\log (m+n))\$.