summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-03-11 18:37:35 (GMT)
committerGuido van Rossum <guido@python.org>1997-03-11 18:37:35 (GMT)
commit0824f63cfc4336b9fc6ff6e2f067a9fcd80aa162 (patch)
treec854f2aeeb4e1c59aeca888cbdf0741d5248cde1 /Python
parent80eb3c02027b435ef1f0eaaa1406b43dd6eebaeb (diff)
downloadcpython-0824f63cfc4336b9fc6ff6e2f067a9fcd80aa162.zip
cpython-0824f63cfc4336b9fc6ff6e2f067a9fcd80aa162.tar.gz
cpython-0824f63cfc4336b9fc6ff6e2f067a9fcd80aa162.tar.bz2
When -O is given, use ".pyo" instead of ".pyc".
Diffstat (limited to 'Python')
-rw-r--r--Python/import.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c
index 37cfdeb..06350b7 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -81,6 +81,14 @@ initimport()
fatal("duplicate initimport() call");
if ((import_modules = newdictobject()) == NULL)
fatal("no mem for dictionary of modules");
+ if (Py_OptimizeFlag) {
+ /* Replace ".pyc" with ".pyo" in import_filetab */
+ struct filedescr *p;
+ for (p = import_filetab; p->suffix != NULL; p++) {
+ if (strcmp(p->suffix, ".pyc") == 0)
+ p->suffix = ".pyo";
+ }
+ }
}
@@ -202,7 +210,7 @@ make_compiled_pathname(pathname, buf, buflen)
if (len+2 > buflen)
return NULL;
strcpy(buf, pathname);
- strcpy(buf+len, "c");
+ strcpy(buf+len, Py_OptimizeFlag ? "o" : "c");
return buf;
}