Skip to content

Commit

Permalink
Avoid flooding iPython display (#2006)
Browse files Browse the repository at this point in the history
This change fixes an issue where the workaround introduced in #1712 for
timing in Jupyter cells could cause some environments (notably VS Code)
to exceed the 500 item limit on displays and prevent other output from
being shown.
  • Loading branch information
swernli authored Nov 5, 2024
1 parent b85a22a commit c5bd585
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pip/qsharp/_qsharp.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,12 @@

# Reporting execution time during IPython cells requires that IPython
# gets pinged to ensure it understands the cell is active. This is done by
# requesting a display id without displaying any content, avoiding any UI changes
# that would be visible to the user.
# simply importing the display function, which it turns out is enough to begin timing
# while avoiding any UI changes that would be visible to the user.
def ipython_helper():
try:
if __IPYTHON__: # type: ignore
from IPython.display import display

display(display_id=True)
except NameError:
pass

Expand Down

0 comments on commit c5bd585

Please sign in to comment.