Atelier des rouesLab FR
Objects/Documentation

etapes23.py

Measuring what the cache retains · etapes23.py

Download ↓
"""Setup, per-query peak and live Python allocations, with optional collection."""
import json,sys,subprocess
from pathlib import Path
from functools import lru_cache
import tracemalloc,gc
from stables18 import graph


def measure(v,cap,ranks,stages=False):
    gc.collect();tracemalloc.start()
    adj=graph();mask=((1<<34)-1)&~(1<<v)&~adj[v]
    @lru_cache(maxsize=cap)
    def poly(rem):
        if not rem:return (1,)
        j=max((i for i in range(34) if rem>>i&1),key=lambda i:(rem&adj[i]).bit_count())
        rest=rem^(1<<j);a=poly(rest);b=(0,)+poly(rest&~adj[j])

Read in context

Comments

Comments from both language editions appear here.

The discussion is open for reading. I’ll enable submissions once spam protection is configured.