[RFC] make 'copy' load quickly

John Arbash Meinel john at arbash-meinel.com
Tue Sep 12 23:56:53 BST 2006


Robert Collins wrote:
> On Tue, 2006-09-12 at 17:45 -0500, John Arbash Meinel wrote:
>> We've known for a while that one of the slowest things to import is
>> 'copy'. This is because it depends on 'inspect' which depends on
>> 'tokenize'. However, the 'copy' only uses 2 functions out of 'inspect',
>> and they are practically trivial.
>>
>> I put together this patch as part of my lazy_import stuff. On my
>> machine, this is the difference:
> 
> I have one concern here, which is how will folk that import bzr first
> get clued in when they import tonekize and stuff is missing.
> 
> Perhaps have a demandload in this module to load the real tokenize if
> the functions from it are used ? Or raise an exception with a full
> explanation and a note that they should import copy before bzrlib ?
> 
> -Rob

Actually, I just hack around 'inspect' then import 'copy', then remove
my hacked 'inspect'.

So actually, it doesn't change anyone who directly loads 'inspect' or
'tokenize'.

In this *specific* instance, I was very careful so that people who use
the other modules get the original modules.

(And if 'inspect' already exists in sys.modules I just import copy and
return)

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/20060912/c71ce23e/attachment.pgp 


More information about the bazaar mailing list