[Numpy-discussion] Should ndarray be a context manager?

Sturla Molden sturla.molden at gmail.com
Wed Dec 10 02:03:17 EST 2014

Nathaniel Smith <njs at pobox.com> wrote:

> @contextmanager
> def tmp_zeros(*args, **kwargs):
>     arr = np.zeros(*args, **kwargs)
>     try:
>         yield arr
>     finally:
>         arr.resize((0,), check_refs=False)

That one is interesting. I have actually never used ndarray.resize(). It
did not even occur to me that such an abomination existed :-)


More information about the NumPy-Discussion mailing list