[IPython-dev] Towards IPython 1.0, the famous big cleanup
Fernando.Perez at colorado.edu
Mon May 16 14:17:06 EDT 2005
Ville Vainio wrote:
> On Sun, 2005-05-15 at 18:08 -0600, Fernando Perez wrote:
>>Yes, there's the need for a table of names per type of special
>>callable, some escaping mechanism for explicit disambiguation (at least
>>for magics), and a bit of extra metadata here and there (command line
>>args, how to access ipython itself, etc.)
> Why is the table needed? Is there an advantage over using good
> old-fashioned modules for this? Considering that there will be no
> name-mangling or anything...
Well, a 'table' is a good old-fashioned dict, so it does have nostalgia value
as well :)
If I stick all that into a module and statically load that, how do I allow
users to define their own, add them at runtime, load them via profiles, etc?
It seems far easier to expose a single make_magic() function (or some similar
simple API) which takes care of stuffing whatever is needed into a dict.
Keep in mind that finding all these things has to be done on _every_ line of
user input in order to match things not recognized as vars before throwing an
exception. I can't think of any better data structure than a dict for this
kind of efficient runtime search (esp. because the C implementation of dicts
has a bunch of nifty fastpaths for string-keyed dicts, which mean this
approach will work fast and clean).
I think we're basically saying the same thing (or almost)... I'm just
thinking of a particular implementation strategy which seems simple to the
user, yet provides the efficiency needed for this component.
More information about the IPython-dev