awkward icon indicating copy to clipboard operation
awkward copied to clipboard

Investigate the usage of `cached_property` for `materialize` and `is_materialized` in `VirtualArray`

Open ikrommyd opened this issue 9 months ago • 3 comments

          Perhaps this is a good candidate for https://docs.python.org/3/library/functools.html#functools.cached_property

Originally posted by @agoose77 in https://github.com/scikit-hep/awkward/pull/3364#discussion_r2002974502

ikrommyd avatar Mar 19 '25 12:03 ikrommyd

Related comment: https://github.com/scikit-hep/awkward/pull/3364#discussion_r2002976282

ikrommyd avatar Mar 19 '25 12:03 ikrommyd

I'm not a big fan of this. We want the option to potentially dematerialize arrays to free up memory. We can now do so by clearing up the _array attribute. My understanding is that cached_property is evaluated once and then cached forever no?

ikrommyd avatar Jun 13 '25 11:06 ikrommyd

I'm not a big fan of this. We want the option to potentially dematerialize arrays to free up memory. We can now do so by clearing up the _array attribute. My understanding is that cached_property is evaluated once and then cached forever no?

Awkward Arrays are immutable by design. I don't think, it is a good idea to cleanup their data buffers. It should be quite inexpensive to make a "virtual" array copy, if needed.

ianna avatar Jun 14 '25 09:06 ianna