]> granicus.if.org Git - python/commitdiff
When -O is given, use ".pyo" instead of ".pyc".
authorGuido van Rossum <guido@python.org>
Tue, 11 Mar 1997 18:37:35 +0000 (18:37 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 11 Mar 1997 18:37:35 +0000 (18:37 +0000)
Python/import.c

index 37cfdeb24e367d46c09881eda26681a18c9c5c2d..06350b78a9b21df4737ac32ef8efd37f8ed3bc6f 100644 (file)
@@ -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;
 }