[MERGE] clean up option.py and branch.py imports

John Arbash Meinel john at arbash-meinel.com
Wed Feb 27 15:28:47 GMT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Hudson wrote:
| So the story of this branch is that I noticed in a traceback that
| option.py lazily imported bzrlib.log then promptly used it at module
| level, which is pointless.  So I removed that, and noticed that some
| other imports were also pointlessly lazy of unused, so I fixed them, so
| I picked another module to work on -- branch.py -- and found a bunch
| more work to do there -- changes so the bzrlib.errors import can be
| properly lazy, and some more unused imports.
|
| As it looks like doing this for all of bzrlib looks like quite a bit of
| work, I thought I'd check here that the work would be acceptable by
| submitting what I've done so far for review.
|
| I guess in the end this should shave a couple of percentage points off
| startup time, but certainly nothing is measurable yet.
|
| Cheers,
| mwh
| PS: I'll see if I can hack up an import checker that undestands lazy
| imports one of these days...
|

BB:approve

I think this is a nice cleanup.

I would probably prefer things to be lazily imported and then used, as long as
there is a chance we won't use it in the future. (you don't need to lazily
import bzrlib.repository when you are defining a repository format, for example.
But something like osutils/trace may stop being used in the future.)

If you want to start tracking down things you can use:

bzr --profile-imports CMD ...

And it will spit out a formatted list of what is getting imported and how long
it is taking. (Similar to the output of --lsprof.) It also shows the time for
compiling regexes because that was one of the big performance issues with
startup time.

Sometimes that reveals some surprising things (why are we importing popen when
we aren't using any of its functions in 'bzr log', etc).

I've gotten busy with other things to run it periodically and clean it up. But I
think it would be reasonable to spend some time doing it.

At the moment, I feel like ConfigObj is one of the things hurting our startup
time, and some of the logging code.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHxYGvJdeBCYSNAAMRAsJbAJ46v+XK1Wy7HxjvsCcR7j0iNPXsQQCeKEVE
bF9c6EmARE+qAO0SCufnchE=
=qPW/
-----END PGP SIGNATURE-----



More information about the bazaar mailing list