[Zope3-dev] Big import blocks
Barry Warsaw
barry@zope.com
20 Mar 2003 11:43:13 -0500
On Thu, 2003-03-20 at 11:26, Guido van Rossum wrote:
> 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
> names. Then instead of
>
> from zope.component import getService, getAdapter
> from zope.publisher.browser import BrowserView
> # etc
>
> you'd write
>
> from zope.app import zapi
>
> and then in the rest of your code you'd write
>
> x = zapi.getService(...)
>
> rather than
>
> x = getService(...)
+1. I'd like to do something similar for zope.storage. The key thing
though is that the name you import should be unique, i.e. I wouldn't
want to see zope.app.api and zodb.api and zodb.storage.api because then
you'd be back to name collisions on "api".
OTOH, perhaps we /should/ call them all "api" and use import-as to
distinguish. Then the rhythm might be:
from zope.app import api as zappapi
from zodb import api as zodbapi
from zodb.storage import api as sapi
etc. OTOOH, perhaps it won't be that likely that a single module will
need to import the entire api of a subsystem.
-Barry