Improve Qt object management and performance (#14700)
This PR tries to address perceived lag in the IPython console when the
`%gui qt` eventloop is enabled
(https://github.com/ipython/ipython/issues/14581) as well as wider
management of Qt objects in said eventloop, initially addressed in
https://github.com/ipython/ipython/issues/14240.
The lag is resolved by setting the timer for exiting the Qt eventloop to
10ms instead of 50ms. This is consistent with the Tk implementation and
removes the observable lag on Windows.
I also took this opportunity to restructure the handling of Qt objects -
the old implementation created a new `QEventLoop` and `QTimer` each time
the inputhook was called. Since `context.input_is_ready()` pretty much
always returns True after 10ms in my tests, this meant creating these
objects anew 20 times per second (or 100 with this proposed timer
patch). https://github.com/ipython/ipython/issues/14240 adds garbage
collection for the `QEventLoop`, but not for the `QTimer` (which is a
feature on Windows only).
I propose creating one instance of `QEventLoop` and `QTimer` initially,
and then just reusing them. In my testing this doesn't improve
performance (Qt is pretty quick at making new objects it seems), but it
does avoid garbage collection issues.
Note that a `QSocketNotifier` _is_ still created every iteration on
POSIX platforms. I'm not sure if that is garbage collected or not. The
value of `context.fileno()` could conceivably change, so we may need to
recreate it as it is done now instead of reusing. I'm not sure, so I
leave it as is.
Let me know if you would rather just change the timer to 10ms to fix
https://github.com/ipython/ipython/issues/14581 and avoid the larger
restructure in this PR. In that case we could only apply this commit:
https://github.com/jdranczewski/ipython/commit/e65cd11a98546af5723251257c03fbaf3d35552b
Add option to suppress pickleshare warning in IPython
Fixes #14416
Add a configuration option to suppress the warning about `pickleshare` dependency when changing directory in IPython.
* Add `suppress_pickleshare_warning` configuration option to the `OSMagics` class in `IPython/core/magics/osm.py`.
* Update the `cd` magic function in `IPython/core/magics/osm.py` to check the `suppress_pickleshare_warning` setting before displaying the warning.
* Add documentation for the new configuration option in `docs/source/config/extensions/storemagic.rst`.
---
For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ipython/ipython/issues/14416?shareId=XXXX-XXXX-XXXX-XXXX).