Remove duplicate is_lexsorted function
State: closed

`_libs.lib` and `_libs.algos` have near-identical `is_lexsorted` functions.  The only differences appear to be small optimizations/modernizations in the `algos` version.  AFAICT the `algos` version is only used in `tests.test_algos` ATM.  This PR removes the `libs._lib` version and changes the one usage (in `indexes.multi`) to use the `algos` version.


Labels:
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves
name: MultiIndex
name: Clean

Comments:
no problem removing can you post a timeit with the perf comparison? (of the is_lexsorted of each version), do we have an asv to cover this?
Weird results from timeit, using one of the examples in asv_bench.multiindex_object and mimicing the usage in MultiIndex.lexsort_depth:

```
import string
import numpy as np
import pandas as pd
from pandas.core.dtypes.common import _ensure_int64
from pandas._libs import lib, algos

mi_large = pd.MultiIndex.from_product(
            [np.arange(1000), np.arange(20), list(string.ascii_letters)],
            names=['one', 'two', 'three'])

self = mi_large
int64_labels = [_ensure_int64(lab) for lab in self.labels]

k = 3
%timeit lib.is_lexsorted(int64_labels[:k])
%timeit algos.is_lexsorted(int64_labels[:k])
```

For k=1, 2, the perf is effectively indistinguishable between the two versions.  For k=3 the libalgos version (the one this PR prefers) is 5000 times slower:

```
In [48]: %timeit lib.is_lexsorted(int64_labels[:k])
The slowest run took 5.17 times longer than the fastest. This could mean that an intermediate result is being cached.
1000000 loops, best of 3: 1.75 µs per loop

In [51]: %timeit algos.is_lexsorted(int64_labels[:k])
100 loops, best of 3: 9.36 ms per loop
```

AFAICT the difference is in the fact that in the k=3 case, lib version returns False, while the algos version calls `free` and then returns False.  In the k=1,2 cases both versions call `free`.

I'd guess that calling free is the right thing to do here, emphasis on "guess".
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=h1) Report
> Merging [#19305](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ca2d2611c5a657720661990e2f3016356e577d1d?src=pr&el=desc) will **decrease** coverage by `0.02%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/19305/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #19305      +/-   ##
==========================================
- Coverage   91.52%    91.5%   -0.03%     
==========================================
  Files         150      150              
  Lines       48875    48875              
==========================================
- Hits        44733    44721      -12     
- Misses       4142     4154      +12
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `89.87% <100%> (-0.03%)` | :arrow_down: |
| #single | `41.66% <100%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/multi.py](https://codecov.io/gh/pandas-dev/pandas/pull/19305/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9tdWx0aS5weQ==) | `96.22% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_converter.py](https://codecov.io/gh/pandas-dev/pandas/pull/19305/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19jb252ZXJ0ZXIucHk=) | `65.22% <0%> (-1.74%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=footer). Last update [ca2d261...b4d3e8f](https://codecov.io/gh/pandas-dev/pandas/pull/19305?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

hmm, that's a memory leak in ``lib.pyx``, ok let's go with the algos one.