Changing the directory where .pyc files are created

Yes, starting from Python 3.8 you can control this behavior. The original discussion starts from pep 304 in 2003. While this original PEP was withdrawn, a variant of this feature was eventually implemented for Python 3.8 in https://bugs.python.org/issue33499 In the result, you can control using PYTHONPYCACHEPREFIX=path, -X pycache_prefix=path and sys.pycache_prefix.

If Python is interpreted, what are .pyc files?

I’ve been given to understand that Python is an interpreted language… This popular meme is incorrect, or, rather, constructed upon a misunderstanding of (natural) language levels: a similar mistake would be to say “the Bible is a hardcover book”. Let me explain that simile… “The Bible” is “a book” in the sense of being a … Read more