From ca2480743b1047ecb42325c2fc1f94b0048c2474 2019-09-05 11:24:00 From: Mohammad Hossein Sekhavat Date: 2019-09-05 11:24:00 Subject: [PATCH] Prevent caching outputs in _, __, ___ when self.cache_size is not positive --- diff --git a/IPython/core/displayhook.py b/IPython/core/displayhook.py index 2128c82..9f160b3 100644 --- a/IPython/core/displayhook.py +++ b/IPython/core/displayhook.py @@ -198,7 +198,7 @@ class DisplayHook(Configurable): """Update user_ns with various things like _, __, _1, etc.""" # Avoid recursive reference when displaying _oh/Out - if result is not self.shell.user_ns['_oh']: + if self.cache_size and result is not self.shell.user_ns['_oh']: if len(self.shell.user_ns['_oh']) >= self.cache_size and self.do_full_cache: self.cull_cache()