Skip to content

perf-002: Hash-map EnvEntry storage #227

Description

@python-processing-unit

Problem

Variable lookup is O(n) linear \strcmp\ scan over \env->entries[]. Paid on every read, write, alias check, and type check. Deep parent-chain walks multiply the cost.

Location: \src/env.c:167-174\ (\env_find_local), all \env_get*/\env_assign*\ paths

Proposed Fix

Add open-addressing hash table to \struct Env\ (keep \entries[]\ for iteration). Insert on \env_define_direct, use for lookup in \env_find_local, \env_get_entry_raw, \env_assign_direct, \env_delete_direct, and alias paths.

Status

Baseline still present — no hash table added to \struct Env\ at \src/env.h:26-32. \env_find_local\ still does linear scan.

Metadata

Metadata

Labels

interpreterRequires a code change in the interpreter.patchRequires a patch version change.performancePerformance improvement.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions