code_junkie

Does python optimize modules when they are imported multiple times?

Nov 12th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. import MyLib
  2. ReallyBigLib = MyLib.SomeModule.ReallyBigLib
  3.  
  4. import MyLib
  5. import ReallyBigLib
  6.  
  7. import MyLib
  8. import ReallyBigLib
  9.  
  10. # module/file a.py
  11. print "Hello from a.py!"
  12. import b
  13.  
  14. # module/file b.py
  15. print "Hello from b.py!"
  16. import a
  17.  
  18. >>> import b
  19. Hello from b.py!
  20. Hello from a.py!
  21. >>> import a
  22. >>>
Add Comment
Please, Sign In to add comment