[CLN] More Misc Cleanups in _libs
cpdef --> cdef in a few cases
modernize string formatting
modernize for loop syntax

Should be orthogonal to other outstanding PR(s)
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22287?src=pr&el=h1) Report
> Merging [#22287](https://codecov.io/gh/pandas-dev/pandas/pull/22287?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/70e6f7c3ce7aca9a0ee08bacb2fe0ad85db02d88?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/22287/graphs/tree.svg?width=650&height=150&src=pr&token=eZ4WkYLtcO)](https://codecov.io/gh/pandas-dev/pandas/pull/22287?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #22287   +/-   ##
=======================================
  Coverage   92.05%   92.05%           
=======================================
  Files         169      169           
  Lines       50709    50709           
=======================================
  Hits        46679    46679           
  Misses       4030     4030
```

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


------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/22287?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/22287?src=pr&el=footer). Last update [70e6f7c...bcff47a](https://codecov.io/gh/pandas-dev/pandas/pull/22287?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 >  are you linting these? (obviously how you made some of the changes)

No, just periodically reading through them.  My vague plan for achieving linting is to get the code (at least some pyx modules) "close enough" to valid python to trick the linter. Had to revert some edits to fix persistent ResourceWarning in one Travis environment.  Will try to narrow down the culprit in the next pass. Ping (got “LGTM” a few days ago) thanks