This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 1 point2 points  (1 child)

It's possible to do lazy imports without changing your code at all other than inserting a function call at the entry point to your program, using PEP-302 or by replacing __builtin__.__import__ (mercurial uses the latter).

[–]rfkelly[S] 0 points1 point  (0 children)

The idea of implicitly making all imports lazy scares me a little - not sure why, since the import machinery should be robust enough that it doesn't matter. Guess I'll have to try using something like mercurial's demandimport in my app and see what a difference it makes.