import keyword behaviour - performance impact if used multiple times?

Andrew James drew at
Sat Nov 27 12:17:23 CET 2004

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:
import psycopg
class A:
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.


Andrew James <drew at>

More information about the Python-list mailing list