[PATCH] better python plugins (well, better IMHO)

John Arbash Meinel john at arbash-meinel.com
Sun Jun 12 17:46:48 BST 2005


Aaron Bentley wrote:

> Lalo Martins wrote:
>
> >Plugins are now loaded on bzrlib
> >initialization, and they're free to register whatever components they
> >like.
>
>
>
> >- John's code has a comment stating subdirectories from the plugin path
> >will be searched one level down; but there was nothing on his code that
> >implemented this.  I didn't add the feature; personally I think it's
> >silly and will slow down startup.
>
>
> You think *that* will slow down startup?  Personally, I think your
> changes will slow down startup, because they require unconditional
> loading of every plug-in the user has installed.  We have already been
> trying to improve startup speed by reducing the number of useless
> imports-- this is a push in exactly the opposite direction.

I agree that searching in subdirectories is just fine. I originally
implemented it, but there was some hesitance, so I pulled it back out to
try and get plugins merged. Which I was very happy to see did occur.

>
> When plugins are just for commands, you can load only the command you
> need.  A simple naming convention means that if you issue the command
> "bzr funky-stuff", bzr can look for funky_stuff.py in the whole plugin
> path, and either load it, or report "no such command".  The only time
> you have to load every plugin is when you're listing all commands.

There are a couple of issues here. First is that you have plugin
commands that operate at the top-most level. So they create a new "bzr
foo" command. But I also agree with Lalo that it is possible to want
lower-level plugins. Perhaps something that adds a new filesystem
protocol. With our discussion of having a BranchStorage object, it could
be very possible to have plugins to support various protocols.

I agree that bzr does have a slightly noticeable overhead for startup
time, because of all the imports it has to do. However, that is usually
only really noticeable the first time after an rsync (since it destroys
all of the .pyc files). And it would be nice to have bzr be very
streamlined so that it only imports things it needs.

>
> That doesn't seem to be the way plugins are currently handled, but it
> could be, and for my money even searching subdirectories under that
> system would be faster than your proposal to load every single plugin
> every time bzr is run.
>
True, but how do you handle the case where you want to add functionality
that is not a command?

> Aaron
>
PS> Just to clarify, I understand your reasoning behind wanting to
search subdirs and I support it. I just wanted to get plugin support
merged. I think Lalo's importing code is done better than mine. It
should be split out into a plugin.py file, and he imports them under the
bzrlib.plugin namespace which is very nice to see.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050612/466763dc/attachment.pgp 


More information about the bazaar mailing list