[Python-Dev] PEP 376 proposed changes for basic plugins support

Éric Araujo merwok at netwok.org
Mon Aug 2 17:08:57 CEST 2010


Le 02/08/2010 14:31, exarkun at twistedmatrix.com a écrit :
> On 12:21 pm, mal at egenix.com wrote:
>> Do we really need to make Python packaging even more complicated by
>> adding support for application-specific plugin mechanisms ?
>>
>> Packages can already work as application plugins by simply defining
>> a plugins namespace package and then placing the plugin packages
>> into that namespace. [...]
>
> This is also roughly how Twisted's plugin system works.  One drawback, 
> though, is that it means potentially executing a large amount of Python 
> in order to load plugins.  This can build up to a significant 
> performance issue as more and more plugins are installed.

If namespace packages make it into Python, they would indeed solve a
part of the problem in a nice, generic way. Regarding the performance
issue, I wonder if functions in pkgutil or importlib could allow one to
iterate over the plugins (i.e. submodules and subpackages of the
namespace package) without actually loading then. We would get only
their names though, not their description or any other information
useful to decide to activate them or not. Maybe importing is the way to
go, with a doc recommendation that people make their plugins subpackages
with an __init__ module containing only a docstring.

Regards



More information about the Python-Dev mailing list