Question: In python's `numpy`, why does `ogrid` always produce `int64` results? 

For my application, I don't want to use `int64` because of memory limitations (which come into play when the output components are broadcast together later). Is there any better alternative than recasting post-hoc:

```
y, x = np.ogrid[:9000,:9000]
y = y.astype(np.int16)
x = x.astype(np.int16)

```

For most other numpy calls a cleaner solution would be to use a `dtype=...` optional argument, but `ogrid` isn't invoked as a function. Instead it seems comparable to operators like `a+b`, except that those usually have alternatives like `np.add(a,b,dtype=np.int8)`.

Answer: 
You can generate the same shapes with `ix_`, and have full control of dtype:

```
In [476]: np.ix_(np.arange(5,dtype=float),np.arange(5,dtype=np.int16))
Out[476]: 
(array([[ 0.],
        [ 1.],
        [ 2.],
        [ 3.],
        [ 4.]]), array([[0, 1, 2, 3, 4]], dtype=int16))
In [477]: np.ogrid[:5,:5]
Out[477]: 
[array([[0],
        [1],
        [2],
        [3],
        [4]]), array([[0, 1, 2, 3, 4]])]

```

`meshgrid` as well:

```
In [488]: np.meshgrid(np.arange(5, dtype=float), np.arange(5, dtype=np.int16), sparse=True, indexing='ij')
Out[488]: 
[array([[ 0.],
        [ 1.],
        [ 2.],
        [ 3.],
        [ 4.]]), array([[0, 1, 2, 3, 4]], dtype=int16)]

```
Another alternative is to use `np.newaxis` more directly:

```
y = np.arange(9000, dtype=np.int16)[:,None]
x = np.arange(9000, dtype=np.int16)[None,:]

```