ENH: intern the constant python strings

Was always intended this way but not done due to a mistake in Python3
fix. Speeds up dictionary lookups a bit as string comparisons can be
skipped on hash collisions.
ENH: avoid searching for __numpy_ufunc__ if its a basic python type

Checking for the attribute is a very large bottlenecks for reductions.
dtype, out, keepdims will often be basic python types so the check can
be skipped.
Also add a couple missing types to helper function _is_basic_python_type
and move it into a header so it can be used in umath.
BUG: Masked arrays and apply_over_axes

Masked arrays version of apply_over_axes did not apply
function correctly to arrays with non-trivial masks.

Fixes #4461.
BUG: fix memory leaks and missing NULL checks

found by cpychecker gcc plugin
Merge pull request #4578 from juliantaylor/static-bugs

BUG: fix memory leaks and missing NULL checks
Merge pull request #4255 from juliantaylor/ufunc-attr-check

__numpy_ufunc__ check improvement
Merge pull request #4463 from abalkin/issue-4461

BUG: Masked arrays and apply_over_axes
ENH: Ensure that repr and str work for MaskedArray non-ndarray bases

For repr, use the name of the base class in output as "masked_<name>"
(with name=array for ndarray to match the previous implementation).
For str, insert masked_print_option in an ndarray view of the object
array that is created for string output, to avoid calling __setitem__
in the base class.  Add tests to ensure this works.