[Zope3-dev] Big import blocks
Guido van Rossum
guido@python.org
Thu, 20 Mar 2003 11:49:21 -0500
> Guido van Rossum writes:
> > So I decided to count. There are currently 4904 "from ... import ..."
> > lines in the entire Zope3 source tree (including tests and
> > zopeproducts). Because many of these are of the form "from X import
>
> I'd actually prefer that imports in the tests be ignored for this
> purpose; a separate "API helper" module can be created for use from
> test modules if it turns out to be needed.
I agree that the four imports from unitest shouldn't be included in
zapi. OTOH I think that the other dead chickens found in the test
modules are representative of code using the Zope 3 API, so I do want
to count those. Here are the unittest imports:
166 unittest.makeSuite
162 unittest.TestCase
156 unittest.TestSuite
154 unittest.main
This means 4 names account for 638 imports. Subtracting these from
the totals, 114 names out of 1724 account for 2492 imports out of a
total of 5995, or 6.6% of the names account for 42% of imports.
> > Assuming this data is roughly correct, we can cut the number of this
> > particular kind of dead chickens roughly in half by creating a module
> > with a short name (e.g. "zapi") that imports the 120 most popular
>
> I think this is a useful analysis, and would love to see something
> like this done instead of continuing the current import hell. A
> script to perform the analysis would be good; additions could be made
> to the API module when something becomes popular enough.
I have a script to perform the analysis; it's just too crummy to
post. :-)
--Guido van Rossum (home page: http://www.python.org/~guido/)