Data Ingestion and Transformation

A Python ingestion job compiles the same regular expression for every input record. Profiling shows compilation consumes most of the runtime; which change should the engineer make?

Show the answer

Correct answerB. Compile the expression once before processing records.

AWhy not this: Larger input batches do not eliminate compilation performed for every record.

BWhy this is right: Reusing a compiled expression eliminates redundant compilation for each record.

CWhy not this: Moving compilation into a helper does not reduce how often it executes.

DWhy not this: More workers retain redundant compilation and introduce distributed execution overhead.

Compiling the unchanged expression once eliminates repeated work in the measured bottleneck. Additional workers might reduce elapsed time, but they retain the unnecessary compilation work and add execution overhead.