Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this issue exists on the latest version of pandas.

  • [X] I have confirmed this issue exists on the main branch of pandas.

Reproducible Example

>>> import pandas as pd 
>>> cat = pd.Categorical(list("bac") * 1_000_000)
>>> %timeit pd.unique(cat._codes)
6.62 ms ± 9.54 µs per loop # v1.5.2
45 ms ± 520 µs per loop # main
>>> %timeit pd.unique(cat)
6.64 ms ± 38.4 µs per loop # v1.5.2
44.8 ms ± 520 µs per loop # main

Installed Versions

INSTALLED VERSIONS ------------------ commit : f94386498f45de70d743a08ebcc334a3ef7c198d python : 3.9.7.final.0 python-bits : 64 OS : Darwin OS-release : 22.3.0 Version : Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103 machine : arm64 processor : arm byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 2.0.0.dev0+1673.gf94386498f numpy : 1.23.4 pytz : 2022.7 dateutil : 2.8.2 setuptools : 65.6.3 pip : 22.3.1 Cython : 0.29.32 pytest : 7.1.2 hypothesis : 6.37.0 sphinx : 5.0.2 blosc : 1.10.6 feather : None xlsxwriter : 3.0.3 lxml.etree : 4.9.1 html5lib : None pymysql : 1.0.2 psycopg2 : 2.9.5 jinja2 : 3.1.2 IPython : 8.9.0 pandas_datareader: None bs4 : 4.11.1 bottleneck : 1.3.5 brotli : fastparquet : 0.8.3 fsspec : 2022.11.0 gcsfs : 2022.11.0 matplotlib : 3.6.2 numba : 0.56.4 numexpr : 2.8.4 odfpy : None openpyxl : 3.0.10 pandas_gbq : None pyarrow : 9.0.0 pyreadstat : None pyxlsb : 1.0.10 s3fs : 2022.11.0 scipy : 1.9.1 snappy : None sqlalchemy : 1.4.43 tables : 3.7.0 tabulate : 0.9.0 xarray : None xlrd : 2.0.1 zstandard : 0.18.0 tzdata : None qtpy : 2.2.0 pyqt5 : None

Prior Performance

No response

Comment From: jbrockmendel

I get 12.4/12.5 ms for main and 12.7/12.7 ms on 1.5.3

Comment From: phofl

Can not see any difference on my machine

1.5.3

%timeit pd.unique(cat._codes)
6.32 ms ± 34.9 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
%timeit pd.unique(cat)
6.33 ms ± 46.5 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

main

%timeit pd.unique(cat._codes)
6.31 ms ± 43.6 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
%timeit pd.unique(cat)
6.39 ms ± 43.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

Comment From: phofl

We would have noticed at least the codes case in our benchmarks as well

Comment From: topper-123

I had a difference in build configuration between the versions. I'll close this. Same with the other.