import keyword behaviour - performance impact if used multiple times?

Andrew James drew at gremlinhosting.com
Sat Nov 27 06:17:23 EST 2004


Hi,
I've been looking around on Google for the answer to this question, and
it's beginning to really bug me. I'm making some design decisions for
some code I'm writing, and I'm wondering whether (Good Design Decisions
apart), there's a performance impact in importing the same module in two
different files. For example, with the following:

fileA.py
-----------
import psycopg
class A:
  ....

fileB.py
import psycopg
class B:
   a = A()
   ....

If I run fileB, will this import the psycopg twice, or once only? Is
this something to do with system modules being singletons?

If someone could help me out with this it would be much appreciated.

Regards,
Andrew

-- 
Andrew James <drew at gremlinhosting.com>




More information about the Python-list mailing list