On Friday 13 July 2007 06:29:59 pm Eric Firing wrote:
> Eric Firing wrote:
> > John Hunter wrote:
> >> On 7/13/07, Ted Drain <[EMAIL PROTECTED]> wrote:
> >>> I think he means that the matplotlib/__init__.py file should be
> >>> changed to that those things are imported.
> >>
> >> but if __init__.py imports axes, and axes import matplotlib, don't we
> >> still have the problem of recursive imports?
> >
> > Yes, but that is not necessarily fatal. It depends on the order in which
> > things are defined and imports are made:
> >
> > http://effbot.org/zone/import-confusion.htm
> >
> > Is there a significant performance penalty, however, in forcing every
> > module to be imported every time any mpl script is run, regardless of
> > whether the module is used in that script?
> >
> > Anyway, I *think* it is feasible to arrange matplotlib.__init__.py so
> > that it imports all the modules, and then use
> >
> > import matplotlib as mpl
> > ... mpl.cbook.is_iterable(x) ...
> >
> > both in scripts and within mpl modules.
>
> I have done a little experimentation, and I am pretty sure this will
> work.  The problem I have run into so far is that in the initial orgy of
> importing, at the end of matplotlib/__init__, one has to be careful
> about the order so that kwdocd entries exist when they are needed.
>
> So, John, is this the direction you would like to go?  It would mean
> that a long list of module imports at the top of each module would go
> away, replaced by the single "import matplotlib as mpl".  This is
> simpler, but it removes the concise information about what modules a
> given module depends on.

I just discovered this in axes.py:

# import a bunch of matplotlib modules into a single namespace
mpl = matplotlib.Importer("""artist, agg, axis, cbook, collections, colors,
     contour, dates, font_manager, image, legend, lines, mlab, cm,
     patches, quiver, table, text, ticker, transforms""")

This seems a little too cute too me, no offense intended to the clever author. 
Why do we need a single namespace? It seems unadvisable. There is additional 
overhead with namespace lookups: running numpy.arange(10) a million times 
takes 15% longer than arange(10). I would have thought it best to do more 
of "from w import x, y, z" 

Darren

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to