[IPython-dev] Should IPython be a singleton?

Brian Granger ellisonbg.net at gmail.com
Wed Aug 26 18:19:47 EDT 2009


> > 1.  We muck with sys.excepthook, sys.displayhook, sys.ipcompleter,
> > sys.stdin, sys.stdout
>
> That doesn't have to be a problem. That's why I wrote all of those *Trap
> classes. And as far as I can tell, sys.ipcompleter is entirely from
> IPython, not
> Python itself. I have no idea why it's in the sys namespace in the first
> place.
>

Yes, your trap classs would help manage all of this for sure.  But we have
a long way to go in the core before the mucking with sys is done in a safe
manner.

As far as ipcompleter, I haven't tracked down exactly why it is there.  But
I do know it is used
from that location in the embedded shell.  But, a proper API should fix
that.

> 2.  We push a number of thing into __builtin__ that point to the
> specific InteractiveShell:
>
> __IPYTHON__
> exit
> quit
> reload

Could be Trapped, as well.
>

Yes.


>
> > 3.  Because of severe cycles in our object graph, an InterativeShell
> > instances can't be
> > garbage collected.
>
> Or rather, they *are* garbage collected and not __del__eted.
>

I have spent some time with gc and muppy/pympler and as of right now, it is
not even garbage collected.  I create and destroy an InteractiveShell
instance
from python (not IPython) and muppy/gc still list it in the live objects.

I haven't had a change to figure out who the offending ref holder is - there

are dozens of them.

> So, should we actually make InteractiveShell a singleton?  There are a
> couple of different
> options:
>
> 1.  One InteractiveShell per process - a true singleton.
> 2.  One InteractiveShell at a time, but multiple (serial) ones in a
process.
> 3.  Multiple, sumultanous InteractiveShells
>
> The only subtlety is that some level of nesting is possible.
>
> Just a note: it will take a lot of refactoring to really implement any
> of the above options.
> But, I want to know what we are aiming for as this issue affects many
> design choices.

#3 would be really, really desirable, and I think it is feasible.
>

I agree, I think it will take some time to refactor things in place and get
this to
be possible.

Cheers,

Brian



>
> --
> 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 at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20090826/efcb4d49/attachment.html>


More information about the IPython-dev mailing list