[IPython-dev] Any reason to keep user_ns() as a call?

Ville Vainio vivainio at gmail.com
Thu May 18 04:58:15 EDT 2006


On 5/18/06, Fernando Perez <fperez.net at gmail.com> wrote:

> I'm starting to use the new api stuff, and was wondering about the
> reasons behind
>
>     def user_ns(self):
>         return self.IP.user_ns
>
> Why not just do
>
> self.user_ns = self.IP.user_ns
>
> in the constructor and access it without the extra function call?  If
> we keep the api module explicitly as 'all members of this represent
> the public API', we don't need to wrap everything into extra function
> calls, which in python have non-negligible cost.
>
> Before I change it, I want to double-check if I'm missing something.

The reasoning is that a function call could theoretically return a
different dictionary at different times. I'm ok with changing it to
represent the dictionary directly, it could be made a property if it
needs to become dynamic. It will require some changes in other parts
of the code, though.

-- 
Ville Vainio - vivainio.googlepages.com
vainio.blogspot.com - g[mail | talk]='vivainio'




More information about the IPython-dev mailing list