My account: Login | Sign Up
Loading... 

Importing again and again | Thread profile

Thread profile page for "Importing again and again" on http://www.dbforums.com. This report page is a snippet summary view from a single thread "Importing again and again", located on the Message Board at http://www.dbforums.com. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity, which are reported in a table below. Additional thread profile information is also shown in the following ways:

1) Top Contributing Authors
2) Related Threads on "eBay Auctions"
3) Related Threads on Other Sites

Warning: These statistics are generated using 'best efforts' and can experience delays and reporting errors at times. Please note that such statistics do not constitute a thread's popularity and/or exact posting volumes at any given reporting period.

Title: Importing again and again
Site: dBforums - Database Support Community  dBforums - Database Support Community - site profile
Forum:    - forum profile
Total authors: 9 authors
Total thread posts: 10 posts
Thread activity: no new posts during last week
Domain info for: dbforums.com

Thread posts in Importing again and again:

1. 
Started 2 years, 4 months ago (2006-06-08 16:02:00)  by abcd
If I have code which imports a module over and over again...say each time a function is called, does that cause Python to actually re-import it...or will it skip it once the module has been imported?? for example: def foo(): import bar bar.printStuff() foo() foo() foo() foo() ....will that re-import bar 4 times...or just import it once? is this a big performance hit? thanks
Size: 381 bytes
Customize:  Customize "Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
2. 
Started 2 years, 4 months ago (2006-06-08 16:32:00)  by Dustan
abcd wrote: > If I have code which imports a module over and over again...say each > time a function is called, does that cause Python to actually re-import > it...or will it skip it once the module has been imported?? > > for example: > > def foo(): > import bar > bar.printStuff() > > foo() > foo() > foo() > foo() > > ...will that re-import bar 4 times...or just import it once? is this a > big ...
Size: 519 bytes
Customize:  Customize "<b>Reply 1</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
3. 
Started 2 years, 4 months ago (2006-06-08 16:48:00)  by John Salerno
abcd wrote: > def foo(): > import bar > bar.printStuff() > > foo() > foo() > foo() > foo() > > ...will that re-import bar 4 times...or just import it once? is this a > big performance hit? > > thanks > Given a file called bar.py with the following contents: print "I'm being imported!" def printStuff(): print 'stuff' I get this output when I import foo.py: >>> import foo I'm being imported! ...
Size: 426 bytes
Customize:  Customize "<b>Reply 2</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
4. 
Started 2 years, 4 months ago (2006-06-08 16:55:00)  by Laszlo Nagy
abcd írta: > If I have code which imports a module over and over again...say each > time a function is called, does that cause Python to actually re-import > it...or will it skip it once the module has been imported?? > > for example: > > def foo(): > import bar > bar.printStuff() > > foo() > foo() > foo() > foo() > > ...will that re-import bar 4 times...or just import it once? Just once. Try ...
Size: 1,181 bytes
Customize:  Customize "<b>Reply 3</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
5. 
Started 2 years, 4 months ago (2006-06-08 17:12:00)  by John Bokma
"abcd" wrote: > If I have code which imports a module over and over again...say each > time a function is called, does that cause Python to actually re-import > it...or will it skip it once the module has been imported?? > > for example: > > def foo(): > import bar > bar.printStuff() > > foo() > foo() > foo() > foo() > > ...will that re-import bar 4 times...or just import it once? is this a > ...
Size: 744 bytes
Customize:  Customize "<b>Reply 4</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
6. 
Started 2 years, 4 months ago (2006-06-08 17:31:00)  by Terry Reedy
"John Bokma" wrote in message news:Xns97DCA4EEBEBEEcastleamber@130.133.1.4... >> def foo(): >> import bar >> bar.printStuff() > I am new to Python so this might be a weird question, but it there a > reason why you import bar inside foo? Two possible reasons: 1) delay import until actually needed, if ever. 2) put 'bar' into the function local namespace instead of the module global namespace ...
Size: 433 bytes
Customize:  Customize "<b>Reply 5</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
7. 
Started 2 years, 4 months ago (2006-06-08 18:42:00)  by John Bokma
"Terry Reedy" wrote: > > "John Bokma" wrote in message > news:Xns97DCA4EEBEBEEcastleamber@130.133.1.4... >>> def foo(): >>> import bar >>> bar.printStuff() >> I am new to Python so this might be a weird question, but it there a >> reason why you import bar inside foo? > > Two possible reasons: > 1) delay import until actually needed, if ever. > 2) put 'bar' into the function local namespace ...
Size: 812 bytes
Customize:  Customize "<b>Reply 6</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
8. 
Started 2 years, 4 months ago (2006-06-08 20:39:00)  by Schüle Daniel
it's import-ed only once # magic.py file #!/usr/bin/python print "here" import magic # try to import itself then try # bad_magic.py #!/usr/bin/python print "here" import bad_magic reload(bad_magic) hth, Daniel
Size: 216 bytes
Customize:  Customize "<b>Reply 7</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
9. 
Started 2 years, 4 months ago (2006-06-09 03:00:00)  by Steve Holden
abcd wrote: > If I have code which imports a module over and over again...say each > time a function is called, does that cause Python to actually re-import > it...or will it skip it once the module has been imported?? > > for example: > > def foo(): > import bar > bar.printStuff() > > foo() > foo() > foo() > foo() > > ...will that re-import bar 4 times...or just import it once? is this a > big ...
Size: 1,078 bytes
Customize:  Customize "<b>Reply 8</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
10. 
Started 2 years, 4 months ago (2006-06-09 04:33:00)  by Maric Michaud
Le Jeudi 08 Juin 2006 22:02, abcd a écrit*: > > def foo(): > import bar > bar.printStuff() > > foo() > foo() > foo() > foo() > > ...will that re-import bar 4 times...or just import it once? is this a > big performance hit? Import a module more than once doesn't execute the code of this module more than once. I don't know what's your need but as some have spoke of reload I just want to warn you,...
Size: 1,278 bytes
Customize:  Customize "<b>Reply 9</b>: Importing again and again :: http://www.dbforums.com :: dBforums - Database Support Community"
 

Top contributing authors for Importing again and again

Name Posts
John Bokma 2
Maric Michaud 1
abcd 1
Dustan 1
John Salerno 1
Laszlo Nagy 1
Terry Reedy 1
Schüle Daniel 1
Steve Holden 1