#3604 perf(mappers): Pre-build static names dict at init time
Pull request opened by
edgarrmondragon on <!date^1776373257^{date_short}|2026-04-16T21:00:57Z>
The names dict passed to simpleeval contains several entries that never
change across records: config,
stream_name,
original_stream_name,
and (optionally) fake. Previously these were assembled from scratch
inside _eval on every single property of every record.
This commit builds those entries once in
init into
_static_eval_names and introduces _build_eval_names(record), which
copies that base dict and merges only the record-level fields. _eval
now calls _build_eval_names instead of performing the inline assembly.
The evaluator and faker are also moved before _init_functions_and_schema
so _static_eval_names can be fully populated before any transform closure
is created.
Co-Authored-By: Claude Sonnet 4.6
noreply@anthropic.com
Summary by Sourcery
Optimize mapper expression evaluation by reusing a pre-built static names dictionary for each record instead of rebuilding it per property.
Enhancements:
• Pre-compute a static simpleeval names dictionary at mapper initialization and reuse it when evaluating expressions for each record.
• Introduce a helper to construct per-record evaluation contexts, separating static and record-specific entries.
• Adjust mapper initialization order and type aliases to better support the shared evaluator and names dictionary.
meltano/sdk