`tf.while_loop` within a `@tf.function` compiles into a single graph operation, eliminating Python interpreter overhead per iteration and enabling static graph optimizations and execution on accelerators, leading to significant speedups compared to native Python loops.