Objets/Documentation
etapes23.py
Mesurer ce que conserve le cache · etapes23.py
Télécharger ↓"""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])