question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

importin `ipdb` is much slower than importing `pdb`

See original GitHub issue

I observe that importing ipdb takes much longer time than pdb almost 120 times on my end. During testing this will increase time to lose for each starting session.

What may be the reason for this (is it a normal case)? Is there any way to make it faster to import ipdb

  • importing ipdb (ipdb==0.13.3)

0.60s user 0.09s system 90% cpu 0.754 total

  • importing ipdb

0.05s user 0.01s system 97% cpu 0.062 total

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adamchainzcommented, Mar 15, 2021

This is fixed by #224 which instantiates IPython lazily.

I timed with hyperfine which does repeated runs and provides statistics.

On master:

$ hyperfine "python -c 'import ipdb'"
Benchmark #1: python -c 'import ipdb'
  Time (mean ± σ):     469.1 ms ±  63.6 ms    [User: 386.2 ms, System: 64.4 ms]
  Range (min … max):   436.5 ms … 647.6 ms    10 runs

With #224 applied:

$ hyperfine "python -c 'import ipdb'"
Benchmark #1: python -c 'import ipdb'
  Time (mean ± σ):     369.6 ms ±   7.5 ms    [User: 310.7 ms, System: 55.8 ms]
  Range (min … max):   360.3 ms … 383.6 ms    10 runs

For reference here’s the import time of just IPython:

$ hyperfine "python -c 'import IPython'"
Benchmark #1: python -c 'import IPython'
  Time (mean ± σ):     367.2 ms ±   5.9 ms    [User: 306.4 ms, System: 56.8 ms]
  Range (min … max):   360.5 ms … 381.2 ms    10 runs
0reactions
avatar-lavventuracommented, Mar 16, 2021

@gotcha Done. // @adamchainz Thanks for the fixed. I never heard hyperfine before, its a great tool

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Update a function during debugging (pdb or ipdb)
Imagine I am debugging the following script: import ipdb def slow_function( ...
Read more >
ipdb no longer works with airflow test command #26352 - GitHub
I used to be able to use ipdb to debug DAGs by running airflow tasks test ... Add ipdb breakpoint anywhere in airflow...
Read more >
ipdb - Bountysource
I observe that importing ipdb takes much longer time than pdb almost 120 times on my end. During testing this will increase time...
Read more >
Does loading PDB slow down execution? - Google Groups
Hi all, If I run a python3 program with "import pdb" in the code, would it execute slower than without loading the debugger?...
Read more >
Python Debugging With Pdb
By default, breakpoint() will import pdb and call pdb.set_trace() , as shown above. However, using breakpoint() is more flexible and allows you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found