Commit 0824f63c authored by Guido van Rossum's avatar Guido van Rossum

When -O is given, use ".pyo" instead of ".pyc".

parent 80eb3c02
...@@ -81,6 +81,14 @@ initimport() ...@@ -81,6 +81,14 @@ initimport()
fatal("duplicate initimport() call"); fatal("duplicate initimport() call");
if ((import_modules = newdictobject()) == NULL) if ((import_modules = newdictobject()) == NULL)
fatal("no mem for dictionary of modules"); 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) ...@@ -202,7 +210,7 @@ make_compiled_pathname(pathname, buf, buflen)
if (len+2 > buflen) if (len+2 > buflen)
return NULL; return NULL;
strcpy(buf, pathname); strcpy(buf, pathname);
strcpy(buf+len, "c"); strcpy(buf+len, Py_OptimizeFlag ? "o" : "c");
return buf; return buf;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment