
March 12, 2020
6:08 p.m.
On Thu, 12 Mar 2020 at 17:42, Eric Wieser <wieser.eric+numpy@gmail.com> wrote:
As an example of these optimizations being valuable, see https://github.com/numpy/numpy/pull/7997, which claims the optimization I described at the beginning resulted in a 1.5x-2x speedup.
This speedup is observed only for large objects. I quote:
Heuristicly it seems to be beneficial around 400kb array sizes (which is about the typical L2 cache size).
I think anyway that this could be a good idea, without changing `del`. The problem is: how can Python knows that a generic operation will create a temporary variable? The change you linked was done specifically for ndarrays, that you know they are immutable. How can Python know that an object is an immutable?