CLN: assorted, mostly typing
diff_2d no longer needs to be in the pxi.in file, so moved it to the pyx

A couple of recently-identified bugs in the groupby code are caused by passing incorrect types, so im getting more motivated to add annotations in/around the affected code.
> but I also feel that this PR covers a little too much ground and could have benefited from being broken up into smaller parts (e.g. typing, Cython refactoring

Totally reasonable.  If others find this a deal-breaker I'll split this up.  Otherwise I'll apply this advice in future CLN PRs this is ok, but generally yes would like to split largish changes. note to @WillAyd this might conflict with your groupby PR?