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.
Merge pull request #4255 from juliantaylor/ufunc-attr-check

__numpy_ufunc__ check improvement