Does loading PDB slow down execution?
bschollnick at schollnick.net
Wed Oct 27 15:47:08 EDT 2021
> On Oct 27, 2021, at 1:01 PM, Unixnut <unixnut at witheredfire.com> wrote:
> On 06/10/2021 18:30, Dieter Maurer wrote:
>> Unixnut wrote at 2021-10-3 22:03 +0100:
>>> If I run a python3 program with "import pdb" in the code, would it
>>> execute slower than without loading the debugger?
>> Importing `pdb` does not slow down the application significantly
>> (it just adds the import time but does not otherwise affect the
>> Only when you execute code under debugger control, the
>> execution is significantly slowed down (because the debugger
>> gets informed (via callbacks) about important "event"s (entering
>> a line, function call, function return, exception) during
>> the execution).
> Excellent, many thanks for confirming. I can leave the execution running then.
But it’s pointless to import pdb, if you aren’t going to use it.
I would suggest that a best practice would be to only import pdb, if and when you were going to be performing the debugging.
(So maybe set a boolean constant, that would cause the import, and debugging code to be executed.
More information about the Python-list