ENH: Compile Factorizer class for all numeric dtypes
State: closed

The current implementation has a couple of ugly side effects in merge:

- uint is cast to int, which causes overflow in some cases
- float is cast to object

This does not enable the classes yet. Will do as a follow up.

Labels:
name: Enhancement
name: Reshaping
description: Concat, Merge/Join, Stack/Unstack, Explode

Comments:
cc @jbrockmendel  would you mind having a look?
Adding factorize to the base class simplifies the follow up
> simplifies the follow up

i guess the follow-up will change how `klass` is found in merge.py?
a few questions, generally looks good
> > simplifies the follow up
> 
> i guess the follow-up will change how `klass` is found in merge.py?

Yeah and also avoids having a million typing errors


thanks @phofl 
This patch may have induced a potential regression. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected appear as subbullets. This is a partially automated message.

 - https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInForObjects.time_isin
   - series_type='long'; vals_type='nans'
 - https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin
   - dtype='Float64'; MaxNumber=1000; series_type='monotone_hits'
   - dtype='float64'; MaxNumber=1000; series_type='monotone_hits'
   - dtype='object'; MaxNumber=1000; series_type='monotone_hits'
   - dtype='object'; MaxNumber=1000; series_type='random_misses'
   - dtype='object'; MaxNumber=5; series_type='monotone_hits'
 - https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin
   - dtype=<class 'numpy.object_'>; M=1000; offset_factor=-2
   - dtype=<class 'numpy.object_'>; M=2000; offset_factor=-2
   - dtype=<class 'numpy.object_'>; M=8000; offset_factor=-2
   - dtype=<class 'numpy.uint64'>; M=1000; offset_factor=-2
   - dtype=<class 'numpy.uint64'>; M=1000; offset_factor=0
   - dtype=<class 'numpy.uint64'>; M=2000; offset_factor=0
   - dtype=<class 'numpy.uint64'>; M=2000; offset_factor=2
   - dtype=<class 'numpy.uint64'>; M=8000; offset_factor=0
I think this is a false positive, looks to me as this is impacted by the klib quadratic probing and seems to go back to normal when this pr was reverted
This patch may have induced a potential regression. Please check the links below. If any ASVs are parameterized, the combinations of parameters that a regression has been detected appear as subbullets. This is a partially automated message.

Subsequent benchmarks may have skipped some commits. See the link below to see which commits are between the two benchmark runs where the regression was identified.

https://github.com/pandas-dev/pandas/compare/c04bba47d09f56101932d673db53a7ae37086132...f6d3cb292e50e77e7cb624ea33167f943c5a2481

 - [algos.isin.IsInForObjects.time_isin](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInForObjects.time_isin)
   - [series_type='long'; vals_type='nans'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInForObjects.time_isin?p-series_type=%27long%27&p-vals_type=%27nans%27)
 - [algos.isin.IsInLongSeriesLookUpDominates.time_isin](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin)
   - [dtype='Float64'; MaxNumber=1000; series_type='monotone_hits'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin?p-dtype=%27Float64%27&p-MaxNumber=1000&p-series_type=%27monotone_hits%27)
   - [dtype='float64'; MaxNumber=1000; series_type='monotone_hits'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin?p-dtype=%27float64%27&p-MaxNumber=1000&p-series_type=%27monotone_hits%27)
   - [dtype='object'; MaxNumber=1000; series_type='monotone_hits'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin?p-dtype=%27object%27&p-MaxNumber=1000&p-series_type=%27monotone_hits%27)
   - [dtype='object'; MaxNumber=1000; series_type='random_misses'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin?p-dtype=%27object%27&p-MaxNumber=1000&p-series_type=%27random_misses%27)
   - [dtype='object'; MaxNumber=5; series_type='monotone_hits'](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin?p-dtype=%27object%27&p-MaxNumber=5&p-series_type=%27monotone_hits%27)
 - [algos.isin.IsinWithArange.time_isin](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin)
   - [dtype=<class 'numpy.object_'>; M=1000; offset_factor=-2](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.object_%27%3E&p-M=1000&p-offset_factor=-2)
   - [dtype=<class 'numpy.object_'>; M=2000; offset_factor=-2](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.object_%27%3E&p-M=2000&p-offset_factor=-2)
   - [dtype=<class 'numpy.object_'>; M=8000; offset_factor=-2](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.object_%27%3E&p-M=8000&p-offset_factor=-2)
   - [dtype=<class 'numpy.uint64'>; M=1000; offset_factor=-2](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.uint64%27%3E&p-M=1000&p-offset_factor=-2)
   - [dtype=<class 'numpy.uint64'>; M=1000; offset_factor=0](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.uint64%27%3E&p-M=1000&p-offset_factor=0)
   - [dtype=<class 'numpy.uint64'>; M=2000; offset_factor=0](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.uint64%27%3E&p-M=2000&p-offset_factor=0)
   - [dtype=<class 'numpy.uint64'>; M=2000; offset_factor=2](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.uint64%27%3E&p-M=2000&p-offset_factor=2)
   - [dtype=<class 'numpy.uint64'>; M=8000; offset_factor=0](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsinWithArange.time_isin?p-dtype=%3Cclass%20%27numpy.uint64%27%3E&p-M=8000&p-offset_factor=0)
The links don't work. But this pr did not touch the code paths that the isin case takes
Reworked my scripts and updated the links, the subbullets now contain links to single parameterization of the benchmark where my code is identifying a regression. But certainly could be a false positive. For example, the first subbullet of [algos.isin.IsInLongSeriesLookUpDominates.time_isin](https://asv-runner.github.io/asv-collection/pandas/#algos.isin.IsInLongSeriesLookUpDominates.time_isin) is an interesting case:

![image](https://user-images.githubusercontent.com/45562402/211714952-c9d68d12-cabe-44e5-95e8-28dce008f899.png)

The first step up points to this PR whereas the second step up is the revert of quadratic programming. Both look like "regressions" but the revert of quadratic programming puts us back to where we started. I'm going to run asvs between certain commits; I'm just curious what's going on here.