py3: remove compat module
check is instance first to short-circuit objects without ndim attributes
use builtin any
add safe size to avoid R-op problems with prod