[IPython-dev] Should IPython be a singleton?

Brian Granger ellisonbg.net@gmail....
Wed Aug 26 18:17:39 CDT 2009


> When tracking down problems like this, one thing you have to be very
> careful
> about is not creating references via your instrumentation. It's
> disturbingly
> easy to do. :-)
>

Yes, it is very tough to do right.


> __builtins__.__IPYTHON__ and __builtins__.__IPYTHON__active are two
> culprits,
> and the remaining one is a cell object. I'm not sure where he is coming
> from.
>

In my version, I have gotten rid of __IPYTHON__ and IPYTHON_active is an
int.

What is a cell object?  Could I see the foo.py script?

These are the game I have been playing, but it would be helpful to see what
you are doing here.

>
>
> [~]$ python foo.py
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>
> 40 references:
> <type 'instancemethod'>
> <bound method InteractiveShell.generate_output_prompt of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.shell_hook of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.show_in_pager of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.pre_prompt_hook of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.pre_runcode_hook of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.clipboard_get of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'dict'>
> A dict with keys: ['app_name', 'IP', 'crash_report_fname',
> 'user_message_template', 'show_crash_traceback', 'contact_email',
> 'bug_tracker',
> 'contact_name']
>
> <type 'instancemethod'>
> <bound method InteractiveShell.dummy_handler of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.ipmagic of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'dict'>
> A dict with keys: ['magic', 'IP', 'user_ns', 'user_global_ns', 'system',
> 'dbg',
> 'meta', 'extensions', 'set_crash_handler', 'set_custom_exc', 'set_hook']
>
> <type 'instancemethod'>
> <bound method InteractiveShell.set_hook of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.set_custom_exc of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.set_crash_handler of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.set_hook of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.ipmagic of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.ipalias of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.ipsystem of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'list'>
> A list of 19524 elements; probably gc.get_objects().
>
> <type 'cell'>
> A cell: <cell at 0x3aab90: InteractiveShell object at 0x3aad90>
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>
>
> <type 'dict'>
> A dict with keys: ['dir_stack', 'ESC_HELP', 'pycolorize', 'SyntaxTB',
> 'indent_current_nsp', 'hooks', 'user_ns', 'user_global_ns', 'system',
> '_main_ns_cache', 'dir_hist', 'autoindent', 'tempfiles', 'BANNER',
> 'code_to_run', 'loghead_tpl', 'ESC_PAREN', 'stdin_encoding', 'usage_min',
> 'has_readline', 'ns_table', 'getoutput', 'no_alias', 'home_dir',
> 'filename',
> 'ESC_SH_CAP', 'ns_refs_table', 'rc', 'usage', 'starting_dir', 'logger',
> 'banner2', 'options_table', 'more', 'shell', 'jobs', 'auto_alias', 'api',
> 'buffer', 'ESC_SHELL', 'alias_table', 'InteractiveTB', 'exit_now',
> 'builtins_added', 'output_hist', 'internal_ns', 'user_config_ns',
> 'ESC_QUOTE2',
> 'custom_exceptions', 'pager', 'sys_excepthook', 'getoutputerror',
> 'esc_handlers', 'input_hist_raw', 'name', 'embedded', 'CACHELENGTH',
> 'strdispatchers', 'CustomTB', '_magic_state', 'compile', 'input_hist',
> 'meta',
> '_user_main_module', 'ESC_MAGIC', 'ESC_QUOTE']
>
> <type 'dict'>
> A dict with keys: ['shell', 'name']
>
> <type 'dict'>
> A dict with keys: ['shell', 'name']
>
> <type 'dict'>
> A dict with keys: ['_dh', '_sh', '__builtins__', 'In', '_ip', '_ih',
> '__name__',
> 'foo', '_oh', 'Out']
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_auto of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_auto of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_auto of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_magic of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_help of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_shell_escape of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.handle_shell_escape of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.generate_prompt of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'dict'>
> A dict with keys: ['log_active', 'shell', '_i', 'log_raw_input', '_i00',
> '_iii',
> 'loghead', 'log_output', 'logfname', '_ii', 'timestamp', '_logmode',
> 'logfile']
>
> <type 'instancemethod'>
> <bound method InteractiveShell.shutdown_hook of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.result_display of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.synchronize_with_editor of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.editor of
> <IPython.core.iplib.InteractiveShell
> object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.fix_error_editor of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.input_prefilter of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'instancemethod'>
> <bound method InteractiveShell.late_startup_hook of
> <IPython.core.iplib.InteractiveShell object at 0x3aad90>>
>
> <type 'dict'>
> A dict with keys: ['obj', 'InteractiveShell', '__builtins__', '__file__',
> 'gc',
> 'refs', '__name__', 'ref', '__doc__', 'types']
>
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless
> enigma
>  that is made terrible by our own mad attempt to interpret it as though it
> had
>  an underlying truth."
>   -- Umberto Eco
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20090826/3ccf67c4/attachment-0001.html 


More information about the IPython-dev mailing list