Patch #602345 by Neal Norwitz and me: add -B option and PYTHONDONTWRITEBYTECODE envvar to skip writing bytecode.
diff --git a/Python/import.c b/Python/import.c
index e191bd5..8094f7d 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -950,8 +950,11 @@
 		if (Py_VerboseFlag)
 			PySys_WriteStderr("import %s # from %s\n",
 				name, pathname);
-		if (cpathname)
-			write_compiled_module(co, cpathname, mtime);
+		if (cpathname) {
+			PyObject *ro = PySys_GetObject("dont_write_bytecode");
+			if (ro == NULL || !PyObject_IsTrue(ro))
+				write_compiled_module(co, cpathname, mtime);
+		}
 	}
 	m = PyImport_ExecCodeModuleEx(name, (PyObject *)co, pathname);
 	Py_DECREF(co);