Mujeeb Ur Rehman
Mujeeb Ur Rehman

Reputation: 87

Does a multi-line statement affects Python interpreter performance?

Consider these two same function calls:

func(arg1, arg2, ...)

and

func(
    arg1,
    arg2,
    ...
)

Does a single line statement performs better than a multi-line one?

Upvotes: 0

Views: 100

Answers (1)

chepner
chepner

Reputation: 530823

No. Both produce the same abstract syntax tree (AST) from which the Python byte code is produced. Only the parser ever sees a difference between the two.

(And yes, I am intentionally ignoring the time it takes the parser to iterate through the extra whitespace in the second example as negligible.)

Upvotes: 3

Related Questions