PERF: tighter cython declarations, faster __iter__
- [ ] closes #xxxx
- [ ] tests added / passed
- [ ] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them
- [ ] whatsnew entry

can you post benchmark changes in the top > Are the ndim=1 additions for readability or performance? Have always just assumed (but never checked) that cython infers it.

When I was working on this I convinced myself that it made a difference, but I can no longer remember why.  Maybe @da-woods can weigh in?

> can you post benchmark changes in the top

It's all going to be micro-perf that asvs don't pick up well > > Are the ndim=1 additions for readability or performance? Have always just assumed (but never checked) that cython infers it.
> 
> When I was working on this I convinced myself that it made a difference, but I can no longer remember why. Maybe @da-woods can weigh in?

https://cython.readthedocs.io/en/latest/src/tutorial/numpy.html#efficient-indexing

> “ndim” keyword-only argument, if not provided then one-dimensional is assumed

I had a quick test of a simple example (looking at the annotated source) and the behaviour looks to match what the docs say. So I think there's no performance advantage to specifying `ndim=1` but you may prefer to be explicit for readability reasons. Thanks @da-woods.

If the `ndim=1` is extraneous, I'm OK with either the more concise or more explicit versions.