Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any disadvantage in using PYTHONDONTWRITEBYTECODE in Docker?

In many Docker tutorials based on Python (such as: this one) they use the option PYTHONDONTWRITEBYTECODE in order to make Python avoid to write .pyc files on the import of source modules (This is equivalent to specifying the -B option).

What are the risks and advantages of setting this option up?

like image 281
floatingpurr Avatar asked Jan 14 '20 10:01

floatingpurr


People also ask

What is the drawback of virtualization in Docker?

Following are disadvantages associated with Docker: Containers don't run at bare-metal speeds. Containers consume resources more efficiently than virtual machines. But containers are still subject to performance overhead due to overlay networking, interfacing between containers and the host system and so on.

Can Docker run bare metal?

Docker is more limited and can run only on Linux, certain Windows servers and IBM mainframes if hosted on bare metal. For example, Docker runs natively only on bare-metal Windows servers running Windows Server 2016 or later.


1 Answers

When you run a single python process in the container, which does not spawn other python processes itself during its lifetime, then there is no "risk" in doing that.

Storing byte code on disk is used to compile python into byte code just upon the first invocation of a program and its dependent libraries to save that step upon the following invocations. In a container the process runs just once, therefore setting this option makes sense.

like image 128
hek2mgl Avatar answered Sep 22 '22 09:09

hek2mgl