REF: cython cleanup, typing, optimizations
Easy parts split off from #23368, #23382.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23456?src=pr&el=h1) Report
> Merging [#23456](https://codecov.io/gh/pandas-dev/pandas/pull/23456?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/93aba79e4fa822b4d029bda795c61d62fe5998e3?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

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

```diff
@@           Coverage Diff           @@
##           master   #23456   +/-   ##
=======================================
  Coverage   92.22%   92.22%           
=======================================
  Files         161      161           
  Lines       51191    51191           
=======================================
  Hits        47210    47210           
  Misses       3981     3981
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.6% <ø> (ø)` | :arrow_up: |
| #single | `42.26% <ø> (ø)` | :arrow_up: |


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23456?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/23456?src=pr&el=footer). Last update [93aba79...afdd39e](https://codecov.io/gh/pandas-dev/pandas/pull/23456?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 thanks