Simplify numpy expression code

* Use a type trait instead of specialization
* Avoid a few copies by using references whenever possible