Why don't python libraries ship as pyc?

If I'm right, Python compilation files are cross-platform. So why do most released libraries require assembly and installation?

Is it laziness on the part of the distributor, or am I mistaken in saying that they can simply distribute pyc files? If this is not the case, how can I distribute a python script file that has libraries as preliminary ones without requiring the user to create and install libraries?

+5
source share
3 answers

Since the format of the contained code can change with each (main) version of Python, although the source code can at least be compatible. The format may also vary between implementations (of which several, the two most famous are CPython and PyPy .

For more information on the internal structure of .pyc files, see this article .

+7
source

They are cross-platform, but not cross-versions, not cross-implementation. In other words, different versions of CPython may have problems with the same .pyc file.

And if you look at other implementations such as PyPy, IronPython, Jython, etc., you are out of luck with .pyc files.

, .pyc .py . , () , , , C. (.pyd,.dll,.so ..) . , .

+4

.pyc .py . , , , script - , , .pyc ( -user-writeable). Python, C, , - , python .

Any library that strictly requires a build step before installing it, of course, has a component that compiles into its own code, which, of course, is not cross-platform. For any pure-python library, it’s always enough to place the source tree of the module source code in your PYTHONPATH by copying it directly from the archive into which you downloaded it.

0
source

All Articles