On Aug 20, 5:43 am, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 20, 8:08 pm, Hussein B <[EMAIL PROTECTED]> wrote: > > > Hey, > > Suppose I have a Python application consists of many modules (lets say > > it is a Django application). > > If all the modules files are importing sys module, how many times the > > sys module will be compiled and executed? > > Only once (the first time the PVM locates, compiles and executes the > > sys module)? or once for each module importing sys? > > Thanks. > > sys is a built-in module, so the answer is zero times. > > For a non-builtin module foo where there exists: > (1) only a foo.py, it will be compiled into foo.pyc > (2) only a foo.pyc, it will be used > (3) both a foo.py and a foo.pyc, Python compiles the foo.py if the pyc > is out of date or (so I believe [*]) was created by a different > version of Python. > > Subsequent imports will use the in-memory copy (in sys.modules, IIRC > [*]) ... > > [*] == Please save me the bother of checking this in the manual :-) > > HTH, > John
One more question: If I have this structure: orig/com/domain/project/Klass1.py Klass2.py __init__.py Why com, domain, project should have __init__.py also? they don't contain source code files? Thanks again. -- http://mail.python.org/mailman/listinfo/python-list