Bazaar-NG vs. Mercurial -- speed comparison
John Arbash Meinel
john at arbash-meinel.com
Thu May 18 21:02:53 BST 2006
Bryan O'Sullivan wrote:
> John A Meinel <john <at> arbash-meinel.com> writes:
...
>> Bzr could be better about not having to load support for all of its
>> features until they are actually needed. 'hg' actually uses a solution
>> called 'demandload', which we probably could just move directly into the
>> bzr code.
>
> You should grab it and use it. It's very nice. It imposes a one-time cost
> when an attribute of a demand-loaded symbol is looked up; after that, the
> importing namespace is patched with the real module, so there's no
> subsequent cost.
>
Well, unfortunately it doesn't really do everything that you might want
it to do. It really only supports importing modules that way. So stuff like:
import bzrlib => demandload(globals(), 'bzrlib') works well.
But this syntax isn't supported at all:
import bzrlib.errors as errors
Though maybe you could do:
demandload(globals(), 'bzrlib:errors')
But that loads the 'errors' member of bzrlib, not the actual module.
In the meantime, I think this does the right thing:
demandload(globals(), 'bzrlib.errors')
errors = bzrlib.errors
Also, something like this:
from bzrlib.errors import (BzrError,
BzrCheckError,
BzrCommandError,
BzrOptionError,
NotBranchError)
looks like you would translate that into:
demandload(globals(), 'bzrlib.errors:BzrError,BzrCheckError,
'BzrCommandError,BzrOptionError,NotBranchError')
But that doesn't work, because demandload._replacer_from requires that
you access an attribute, and __call__ doesn't seem to count.
So I'll keep playing, but in the meantime it isn't just a drop-in
replacement.
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060518/b7a1edaf/attachment.pgp
More information about the bazaar
mailing list