PERF: Use fused types for map_infer_mask
State: closed

- [ ] closes #xxxx (Replace xxxx with the GitHub issue number)
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

Just a hack at this point, seeing if this is a terrible idea. This takes us from a 40% perf hit using Cython 3.0.4 (from #55179) to a 35% perf improvement  for `strings.Methods.time_len('string[python]')`. I haven't run a full ASV yet, but can if this seems at all viable. I'm not certain if the fused types really cover all uses for map_infer_mask (the test suite seems to think so).

cc @jbrockmendel @WillAyd 

<details>
<summary>ASVs</summary>

```
| Change   | Before [984d7554] <main>   | After [c4bdb1aa] <perf_map_infer_mask_fused>   |   Ratio | Benchmark (Parameter)                                                                                         |
|----------|----------------------------|------------------------------------------------|---------|---------------------------------------------------------------------------------------------------------------|
| -        | 197±4μs                    | 178±5μs                                        |    0.91 | algos.isin.IsInForObjects.time_isin('nans', 'short')                                                          |
| -        | 12.9±0.05ms                | 11.7±0.04ms                                    |    0.91 | strings.Methods.time_endswith('str')                                                                          |
| -        | 15.8±0.2ms                 | 14.3±0.07ms                                    |    0.91 | strings.Methods.time_title('str')                                                                             |
| -        | 146±10μs                   | 132±0.8μs                                      |    0.9  | algos.isin.IsIn.time_isin_mismatched_dtype('object')                                                          |
| -        | 8.28±0.2ms                 | 7.44±0.07ms                                    |    0.9  | frame_methods.Dropna.time_dropna_axis_mixed_dtypes('any', 1)                                                  |
| -        | 10.4±0.07ms                | 9.42±0.1ms                                     |    0.9  | frame_methods.Equals.time_frame_object_unequal                                                                |
| -        | 11.9±0.5μs                 | 10.7±0.2μs                                     |    0.9  | frame_methods.GetNumericData.time_frame_get_numeric_data                                                      |
| -        | 630±2μs                    | 569±2μs                                        |    0.9  | libs.InferDtype.time_infer_dtype('np-object')                                                                 |
| -        | 6.03±0.6μs                 | 5.40±0.02μs                                    |    0.9  | series_methods.Any.time_any(1000000, 'fast', 'bool')                                                          |
| -        | 9.41±0.03ms                | 8.50±0.1ms                                     |    0.9  | strings.Contains.time_contains('str', False)                                                                  |
| -        | 16.4±0.04ms                | 14.9±0.2ms                                     |    0.9  | strings.Methods.time_get('string[python]')                                                                    |
| -        | 18.0±0.4ms                 | 16.3±0.2ms                                     |    0.9  | strings.Methods.time_match('str')                                                                             |
| -        | 12.6±0.1ms                 | 11.3±0.09ms                                    |    0.9  | strings.Methods.time_upper('string[python]')                                                                  |
| -        | 8.36±0.1ms                 | 7.51±0.05ms                                    |    0.9  | strings.Methods.time_zfill('str')                                                                             |
| -        | 9.06±0.4μs                 | 8.05±0.03μs                                    |    0.89 | frame_ctor.FromNDArray.time_frame_from_ndarray                                                                |
| -        | 15.4±0.08ms                | 13.6±0.09ms                                    |    0.89 | strings.Methods.time_find('string[python]')                                                                   |
| -        | 8.59±0.2ms                 | 7.66±0.05ms                                    |    0.89 | strings.Methods.time_isupper('str')                                                                           |
| -        | 13.0±0.02ms                | 11.5±0.02ms                                    |    0.89 | strings.Methods.time_slice('string[python]')                                                                  |
| -        | 11.3±0.04ms                | 9.94±0.2ms                                     |    0.88 | frame_methods.Equals.time_frame_object_equal                                                                  |
| -        | 13.2±0.2ms                 | 11.7±0.07ms                                    |    0.88 | indexing.DataFrameNumericIndexing.time_loc_dups(<class 'numpy.float64'>, 'nonunique_monotonic_inc')           |
| -        | 13.3±0.2ms                 | 11.7±0.07ms                                    |    0.88 | indexing.DataFrameNumericIndexing.time_loc_dups(<class 'numpy.float64'>, 'unique_monotonic_inc')              |
| -        | 28.5±0.7ms                 | 25.0±1ms                                       |    0.88 | join_merge.ConcatDataFrames.time_c_ordered(0, False)                                                          |
| -        | 762±0.7μs                  | 674±3μs                                        |    0.88 | libs.InferDtype.time_infer_dtype_skipna('np-object')                                                          |
| -        | 10.3±0.01ms                | 9.11±0.05ms                                    |    0.88 | strings.Methods.time_isalnum('str')                                                                           |
| -        | 9.06±0.04ms                | 7.97±0.01ms                                    |    0.88 | strings.Methods.time_istitle('str')                                                                           |
| -        | 8.76±0.1ms                 | 7.67±0.03ms                                    |    0.88 | strings.Methods.time_lstrip('str')                                                                            |
| -        | 9.11±0.02ms                | 8.00±0.04ms                                    |    0.88 | strings.Methods.time_lstrip('string[python]')                                                                 |
| -        | 8.72±0.02ms                | 7.69±0.03ms                                    |    0.88 | strings.Methods.time_rstrip('str')                                                                            |
| -        | 8.83±0.06ms                | 7.79±0.02ms                                    |    0.88 | strings.Methods.time_zfill('string[python]')                                                                  |
| -        | 297±8μs                    | 258±9μs                                        |    0.87 | arithmetic.IntFrameWithScalar.time_frame_op_with_scalar(<class 'numpy.float64'>, 5.0, <built-in function gt>) |
| -        | 284±20μs                   | 246±20μs                                       |    0.87 | arithmetic.IntFrameWithScalar.time_frame_op_with_scalar(<class 'numpy.int64'>, 2, <built-in function lt>)     |
| -        | 17.5±0.6ms                 | 15.2±0.06ms                                    |    0.87 | strings.Methods.time_fullmatch('string[python]')                                                              |
| -        | 8.77±0.03ms                | 7.66±0.06ms                                    |    0.87 | strings.Methods.time_isalpha('str')                                                                           |
| -        | 8.69±0.04ms                | 7.60±0.07ms                                    |    0.87 | strings.Methods.time_islower('str')                                                                           |
| -        | 7.28±0.09ms                | 6.34±0.03ms                                    |    0.87 | strings.Methods.time_isnumeric('str')                                                                         |
| -        | 12.1±0.1ms                 | 10.5±0.04ms                                    |    0.87 | strings.Methods.time_normalize('string[python]')                                                              |
| -        | 16.1±0.4ms                 | 14.0±0.4ms                                     |    0.87 | strings.Methods.time_rfind('string[pyarrow]')                                                                 |
| -        | 9.12±0.05ms                | 7.96±0.02ms                                    |    0.87 | strings.Methods.time_rstrip('string[python]')                                                                 |
| -        | 9.06±0.05ms                | 7.85±0.2ms                                     |    0.87 | strings.Methods.time_strip('str')                                                                             |
| -        | 1.23±0.05ms                | 1.06±0.04ms                                    |    0.86 | frame_methods.Fillna.time_bfill(True, 'datetime64[ns, tz]')                                                   |
| -        | 7.36±0.04ms                | 6.32±0.05ms                                    |    0.86 | strings.Methods.time_isdecimal('str')                                                                         |
| -        | 8.87±0.2ms                 | 7.61±0.06ms                                    |    0.86 | strings.Methods.time_lower('str')                                                                             |
| -        | 9.31±0.09ms                | 8.00±0.02ms                                    |    0.86 | strings.Methods.time_lower('string[python]')                                                                  |
| -        | 12.7±0.3ms                 | 10.8±0.3ms                                     |    0.86 | strings.Methods.time_slice('str')                                                                             |
| -        | 76.8±0.7ms                 | 65.8±0.3ms                                     |    0.86 | strings.Slice.time_vector_slice                                                                               |
| -        | 13.7±0.2ms                 | 11.6±0.03ms                                    |    0.85 | strings.Contains.time_contains('string[python]', True)                                                        |
| -        | 11.5±0.2ms                 | 9.72±0.06ms                                    |    0.85 | strings.Methods.time_endswith('string[python]')                                                               |
| -        | 7.40±0.01ms                | 6.32±0.05ms                                    |    0.85 | strings.Methods.time_isdigit('str')                                                                           |
| -        | 7.02±0.1ms                 | 5.95±0.02ms                                    |    0.85 | strings.Methods.time_isspace('str')                                                                           |
| -        | 11.9±0.2ms                 | 10.1±0.02ms                                    |    0.85 | strings.Methods.time_normalize('str')                                                                         |
| -        | 11.9±0.1ms                 | 10.1±0.02ms                                    |    0.85 | strings.Methods.time_replace('string[python]')                                                                |
| -        | 16.5±0.2ms                 | 14.1±0.1ms                                     |    0.85 | strings.Methods.time_rfind('string[python]')                                                                  |
| -        | 9.51±0.07ms                | 8.11±0.02ms                                    |    0.85 | strings.Methods.time_strip('string[python]')                                                                  |
| -        | 12.4±0.1ms                 | 10.5±0.2ms                                     |    0.85 | strings.Methods.time_upper('str')                                                                             |
| -        | 16.9±0.2ms                 | 14.2±0.08ms                                    |    0.84 | strings.Methods.time_match('string[python]')                                                                  |
| -        | 11.9±0.1ms                 | 9.80±0.03ms                                    |    0.82 | strings.Methods.time_replace('str')                                                                           |
| -        | 11.1±0.04ms                | 9.07±0.08ms                                    |    0.81 | strings.Methods.time_startswith('string[python]')                                                             |
| -        | 9.37±0.01ms                | 7.52±0.03ms                                    |    0.8  | strings.Methods.time_isalnum('string[python]')                                                                |
| -        | 8.32±0.05ms                | 6.58±0.04ms                                    |    0.79 | strings.Contains.time_contains('string[python]', False)                                                       |
| -        | 8.08±0.1ms                 | 6.36±0.01ms                                    |    0.79 | strings.Methods.time_istitle('string[python]')                                                                |
| -        | 4.89±0.2ms                 | 3.83±0.2ms                                     |    0.78 | libs.FastZip.time_lib_fast_zip                                                                                |
| -        | 16.5±0.2ms                 | 12.9±0.1ms                                     |    0.78 | strings.Methods.time_count('string[python]')                                                                  |
| -        | 22.5±0.1ms                 | 17.3±0.1ms                                     |    0.77 | frame_methods.Fillna.time_bfill(True, 'object')                                                               |
| -        | 7.73±0.03ms                | 5.93±0.04ms                                    |    0.77 | strings.Methods.time_isalpha('string[python]')                                                                |
| -        | 7.79±0.04ms                | 6.04±0.02ms                                    |    0.77 | strings.Methods.time_islower('string[python]')                                                                |
| -        | 7.87±0.03ms                | 6.05±0.01ms                                    |    0.77 | strings.Methods.time_isupper('string[python]')                                                                |
| -        | 6.56±0.03ms                | 4.80±0.03ms                                    |    0.73 | strings.Methods.time_isdecimal('string[python]')                                                              |
| -        | 6.62±0.03ms                | 4.80±0ms                                       |    0.73 | strings.Methods.time_isnumeric('string[python]')                                                              |
| -        | 6.59±0.02ms                | 4.76±0.03ms                                    |    0.72 | strings.Methods.time_isdigit('string[python]')                                                                |
| -        | 6.19±0.02ms                | 4.43±0.03ms                                    |    0.71 | strings.Methods.time_isspace('string[python]')                                                                |
| -        | 4.83±0.04ms                | 3.00±0.02ms                                    |    0.62 | strings.Methods.time_len('string[python]')                                                                    |
```

</details>

Labels:
name: Performance
description: Memory or execution speed performance
name: Dtype Conversions
description: Unexpected or buggy dtype conversions

Comments:
Can you add a whatsnew? Otherwise, LGTM.
If there are no objections, I'd like to try to get this in tonight so I can rerun ASVs in #55179
Thanks @rhshadrach