The python sys module has a field called sys.dont_write_bytecode If it is set to True "Python won’t try to write .pyc files on the import of source modules". See the doc here
sys.dont_write_bytecode