Search code examples
pythonpyc

Why are python libraries not supplied as pyc?


If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install?

Is it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file that has libraries as prerequist without requiring the user to build and install the libraries?


Solution

  • Because the format of the contained code can change with each (major) Python release, while source code at least can be compatible. The format can also differ between implementations (of which there are several, the two most well-known are CPython and PyPy.

    See this article for more information about the internal structure of .pyc files.