Skip to content

lazy or not lazy #410

Answered by davidhassell
rich-HJ asked this question in Q&A
Jun 20, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi @rich-HJ

Good question! There is the Data.in_memory attribute:

>>> f.data.in_memory
False

but that only returns True if all of the data is in memory. Maybe that is what you need (?), but if any chunk of it is still lazy then it returns False.

If you want to a more granular approach, it's easy to write a little function that will do something a bit finer, following on from the approach of https://github.com/NCAS-CMS/cf-python/blob/v3.12.0/cf/data/data.py#L12180-L12196. E.g.

def percentage_of_data_in_memory(f):
    size_in_memory = 0
    for partition in f.data.partitions.matrix.flat:
        if partition.in_memory:
            size_in_memory += partition.size
 
    return 100 * size_in_…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rich-HJ
Comment options

Answer selected by rich-HJ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants