[IPython-dev] Should we disable autocall by default from now on?

Robert Kern robert.kern@gmail....
Wed Nov 30 05:18:52 CST 2011

On 11/30/11 7:07 AM, Fernando Perez wrote:
> Hi folks,
> over the years, we've had a number of bug reports that ultimately boil
> down to ipython doing an extra getattr call on objects at the prompt,
> such as
> https://github.com/ipython/ipython/issues/988
> https://github.com/ipython/ipython/issues/851
> While this may appear odd, people do have code out there that mutates
> the state of objects on simple getattr calls, and so *any*
> introspection on such objects, no matter how carefully done, mutates
> them.  The last example comes from Traits code, which is famous for
> having complex semantics attached to attribute access.
> Since this is a recurring problem, I'm trying to decide whether the
> convenience of autocall being on by default is worth against the
> occasional surprise of situations like these.
> Obviously we'd leave the functionality of autocall as-is, and people
> could still enable it if they wanted to.  I'm only talking about
> whether it should be completely off by default.  The reason why
> defaults matter a lot is that the vast majority of users never ever
> change them (I've seen countless long-term users with the wrong colors
> for a light bacgkround, the one default we can't pick for them and
> that leads to unreadable tracebacks, yet people live with it for
> years).  So it's up to us to give people defaults that lead to the
> best experience possible.
> I personally had always fallen on the side of saying that autocall is
> a big convenience of ipython, and that code that mutates on simple
> attribute access is special enough that we shouldn't sacrifice that
> convenience for most users to accommodate such a special case.

I don't think it's *that* special of a case. There are all kinds of good reasons 
to set up a special case for the first time an attribute is looked up while 
mutating the object to let future lookups go through a different path. 
*Usually*, getting the attribute in the autocall code is innocuous, but 
sometimes it isn't.

I've always been in favor of turning autocall off by default, though I can't 
really say that I have a strong argument beyond personal preference. I don't 
like to keep two parallel Python syntaxes in my head (and muscle memory!), 
especially when one of them is only informally specified and only works in one 
specific environment.

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

More information about the IPython-dev mailing list