REF: Cleanups, typing, memoryviews in tslibs
- [ ] closes #xxxx
- [ ] tests added / passed
- [ ] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23368?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@4f71755`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `n/a`.

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

```diff
@@            Coverage Diff            @@
##             master   #23368   +/-   ##
=========================================
  Coverage          ?   92.22%           
=========================================
  Files             ?      161           
  Lines             ?    51191           
  Branches          ?        0           
=========================================
  Hits              ?    47210           
  Misses            ?     3981           
  Partials          ?        0
```

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


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23368?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/23368?src=pr&el=footer). Last update [4f71755...f57f994](https://codecov.io/gh/pandas-dev/pandas/pull/23368?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 @jbrockmendel : For the less initiated, could you explain the rationale for your changes? Good thinking, gotta keep me on my toes.

The most common change is changing e.g. `ndarray[int64_t]` to `int64_t[:]`.  This is the more modern suggested usage in cython, is more general, _slightly_ more performant, and moved towards decoupling from a numpy back-end.

Adding `@cython.boundscheck(False)` and `@cython.wraparound(False)` improves performance slightly, is safe in cases where we know all array-lookups have valid indices.

Many of the remaining changes are using py3-style type annotations instead of cython type annotations (cython supports this even in py2).  This moves us in the direction of being valid python, which hopefully one day we can lint. @jbrockmendel : Given the amount of work you have done cleaning up the internals, I'm starting to think that it would be good to add something to the contribution docs about writing good `Cython` code (so that I won't be asking every time why you make the changes that you do 🙂 ).

What do you think? Reverted change of `foo.base` to `np.assarray(foo)`.  It risks incorrectly returning `np.array(None)` instead of raising. needs a rebase Rebased, but please hold off pending another pass. The worthwhile parts of this are in #23464.  Closing.