Search code examples
pythondjangotraceback

python `traceback` production performance


I'm using try catch blocks to handle exceptions in my Django app. However, I'm also using traceback module to print debug information in case an exception is caught.

try:
   # Exception gets thrown here
except:
   traceback.print_exc()

Should I remove this when moving into production? Does this have significant performance consequences (like xdebug in PHP, for instance)?


Solution

  • No, there are no significant performance implications to this; the traceback is already present with the exception when it is raised.

    All traceback.print_exc() does is print the information already there.