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

Julian Taylor jtaylor.debian at googlemail.com
Tue Dec 9 12:57:59 EST 2014


On 09.12.2014 18:55, Sturla Molden wrote:
> On 09/12/14 18:39, Julian Taylor wrote:
> 
>> A context manager will also not help you with reference cycles.
> 
> If will because __exit__ is always executed. Even if the PyArrayObject 
> struct lingers, the data buffer will be released.
> 


a exit function would not delete the buffer, only decrease the reference
count of the array. If something else still holds a reference it stays
valid.
Otherwise you would end up with a crash when the other object holding a
reference tries to access it.




More information about the NumPy-Discussion mailing list