numpy/numpy — pull request #2760 by rhattersley (2012-11-22 16:57:27+00:00)
Title: A quicker way to set mask values.

Whilst profiling a library which uses NumPy I came across the following:
```python
data = numpy.ma.zeros(array_shape)
data.mask = True
```

It turns out the assignment to the mask is very slow because MaskedArray.__setmask__() is using the `flat` iterator. This pull request swaps that for ellipsis indexing which is much, much faster.

For the record, a workaround in this case is:
```python
raw_data = numpy.empty(array_shape)
mask = numpy.ones(array_shape, dtype=numpy.bool)
data = numpy.ma.MaskedArray(raw_data, mask=mask)
```