[Tutor] __debug__ and PYTHONOPTIMIZE

Albert-Jan Roskam sjeik_appie at hotmail.com
Mon Jul 4 18:31:07 EDT 2022


   Hi, 
   I am using PYTHONOPTIMIZE=1 (equivalent to start-up option "-o"). As I
   understood, assert statements are "compiled away" then. But how about
   __debug__. Does it merely evaluate to False when using "-o"? Or is it also
   really gone? More generally; how do I decompile a .pyc or .pyo file to
   verify this? With the "dis" module? This is a relevant code snippet:
   for record in billionrecords:
       if __debug__:  #evaluating this still takes some time!
           logger.debug(record)
   Thanks!
   Albert-Jan


More information about the Tutor mailing list