Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions muninn/consolidation/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,18 @@ async def _phase_decay(self) -> dict:
record_ids, lookback_days=30, estimator="snips"
)

for record in records:
# Get centrality from pre-fetched map
centrality = centrality_map.get(record.id, 0.0)

# Get max similarity for novelty calculation
max_sim = 0.0 # Would need vector lookup β€” simplified for now
c_get = centrality_map.get
u_get = utility_map.get

# SNIPS retrieval utility from pre-fetched batch map
ret_util = utility_map.get(record.id, 0.0)
for record in records:
rid = record.id

# Recalculate importance
new_importance = calculate_importance(
record,
max_similarity=max_sim,
centrality=centrality,
retrieval_utility=ret_util,
max_similarity=0.0, # Would need vector lookup β€” simplified for now
centrality=c_get(rid, 0.0),
retrieval_utility=u_get(rid, 0.0),
)
Comment on lines +207 to 219
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While caching the .get method reference is a common Python micro-optimization, it is redundant here because the centrality_map and utility_map are guaranteed to contain all keys from record_ids (as implemented in the batch fetch calls on lines 202-203). Using direct dictionary access centrality_map[rid] is more efficient than c_get(rid, 0.0) as it avoids the function call overhead and the internal logic for handling default values. This also simplifies the code by removing the need for intermediate method reference variables.

        for record in records:
            rid = record.id

            # Recalculate importance
            new_importance = calculate_importance(
                record,
                max_similarity=0.0, # Would need vector lookup β€” simplified for now
                centrality=centrality_map[rid],
                retrieval_utility=utility_map[rid],
            )
References
  1. Optimal Reasoning: Question every assumption. The assumption that .get() with a default is necessary is incorrect here because the maps are pre-populated with all relevant keys during the batch-fetching phase. (link)


if new_importance != record.importance:
Expand Down
Loading