CLN: avoid runtime imports
Edits to lib.is_scalar are to put slower python-space checks later so they may get short-circuited.

Everything else should be self-explanatory.
> any perf differences?

PR
```
In [3]: %timeit is_scalar(None)                                                                                                                                                                                                                   
55.1 ns ± 0.745 ns per loop (mean ± std. dev. of 7 runs, 10000000 loops each)
```

master
```
In [3]: %timeit is_scalar(None)                                                                                                                                                                                                                   
588 ns ± 25.7 ns per loop (mean ± std. dev. of 7 runs, 1000000 loops each)
```

Presumably anything that is caught by the `isinstance(Fraction, Number)` would take a hit, but the difference when I pass an int or float is within the margin of error, and it isn't clear what else would be caught by that isinstance check.  Also no difference when passing a list, which is what we'd expect. i will look at things tomorrow ping thanks