Code review comment for lp:~jml/bzr/lp-login-oauth-2

Revision history for this message
John A Meinel (jameinel) wrote :

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

Martin Pool wrote:
> 2009/12/16 Jonathan Lange <email address hidden>:
>>> Also, it seems like it might be nicer to lazily import lp_registration.
>>> I wouldn't expect a huge improvement to bzr startup time, but maybe
>>> something?
>>>
>>> Anyway, nothing you have to tweak, just a surprise on my part.
>>>
>> I tried to change this to use lazy_import. It turns out to be a whole bunch of hard.
>
> jml and i looked at this - lazy import is no better than just not
> loading the submodule til it's needed, and as it turns out it's
> harder.
>

Yeah, lazy import + deciding whether or not to do something based on
whether it is available is ... tricky. Because the import occurs during
the attribute lookup.

If we want to make it a dependency that py2exe won't find, then we would
do something like:

try:
  lp_api = __import__('lp_api')
except ImportError:
  ...

If it still finds it, then

lazy_import(globals(), """
import lp_api
""")
try:
  getattr(lp_api, 'foo', None)
except ImportError:
 ...

It is pretty ugly, and I think we can just add a "don't include X" to
the setup.py code rather than hack around it that way.

John
=:->

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

iEYEARECAAYFAkso8YMACgkQJdeBCYSNAAOjhwCeOfU+S9+LHny7f/6n5ZedqEy5
YIUAn3mC7p+fX4JyeyagDnofY02WC6/O
=aDGj
-----END PGP SIGNATURE-----

« Back to merge proposal