Surprising Python quirk

Revision en1, by SoleProprietor, 2023-01-07 02:47:50

I have two almost identical submissions getting a substantial difference in execution time:

TLE submission uses variable MOD inside the main function:

def main():
    MOD = 998244353  # local var
    ...
main()

and the AC submission uses variable MOD outside:

MOD = 998244353 # global var
def main():
    ...
main()

Any idea what causes such a difference in performance?

Tags python, execution time

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English SoleProprietor 2023-01-07 02:47:50 562 Initial revision (published)