简体   繁体   English

Python:`dist`和`sdist`之间有性能差异吗?

[英]Python: Is there a performance difference between `dist` and `sdist`?

Python setuptools can create a source distribution: Python setuptools可以创建源代码分发:

python setup.py sdist # create a source distribution (tarball, zip file, etc.)

Or a binary distribution: 或二进制分发:

python setup.py bdist   # create a built (binary) distribution

As far as I understand, there should not be any performance difference: 据我了解,不应有任何性能差异:

  • bdist installs the already-compiled .pyc files from the binary package. bdist从二进制包安装已编译的.pyc文件。
  • sdist compiles the .py files to .pyc files, and installs them. sdist.py文件编译为.pyc文件,然后安装它们。

When executed it should not matter how were the .pyc files compiled - they should have the same performance. 执行时,编译.pyc文件的方式无关紧要 - 它们应具有相同的性能。

Is there any performance difference between dist and sdist python packages? distsdist python包之间有任何性能差异吗?

If you have a pure Python code, the difference in time deploying will be slim. 如果您有纯Python代码,那么部署时间的差异将很小。 Note that there is no difference in performance between .py and .pyc , except that the latter will be read slightly faster the first time. 请注意, .py.pyc之间的性能没有差别,除了后者第一次读取稍快一些。 The so called optimised .pyo only strip the asserts, and optionally, get rid of the docstrings, so they are not very much optimised. 所谓的优化 .pyo只剥离断言,并且可选地去除文档字符串,因此它们没有得到很好的优化。

The big difference comes when you have C files. 当你有C文件时,差别很大。 sdist will include them if properly referenced, but the user will need a working and appropiate compiler, Python header files, and so on. 如果正确引用, sdist将包含它们,但是用户将需要一个有效的编译器,Python头文件等等。 Also, you will have to take the time to build them on every client. 此外,您将不得不花时间在每个客户端上构建它们。 The same distribution will be valid for any platform you deploy in. 相同的分发对您部署的任何平台都有效。

On the other hand, bdist compiles the code once. 另一方面, bdist编译一次代码。 Installing in the client is immediate, as they don't need to build anything, and easier as they don't require a compiler installed. 在客户端安装是立竿见影的,因为它们不需要构建任何东西,并且因为它们不需要安装编译器而更容易。 The downside is that you have to build for that platform. 缺点是你必须为该平台构建。 Setuptools is capable of doing cross-compilation, provided you have installed and configured the right tools. 只要您安装并配置了正确的工具,Setuptools就能够进行交叉编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 'sdist'.tar.gz 发行版和 python 鸡蛋有什么区别? - What is the difference between an 'sdist' .tar.gz distribution and an python egg? Python 性能问题:两个多边形之间的差异 - Python performance problem: difference between two polygons 测量 Python 和 Java 实现之间的性能差异? - Measuring performance difference between Python and Java implementations? Python 中 for 和 while 循环之间的性能差异 - Performance difference between for and while loop in Python 基准测试JS和Python之间的性能差异 - Benchmarking performance difference between JS and Python python-两种实现之间的性能差异 - python - performance difference between the two implementations “if”和“if not”之间的性能或风格差异? - Performance or style difference between “if” and “if not”? 为什么Python和Cython中这两个代码之间存在巨大的性能差异? - Why there is a huge performance difference between these two codes in Python and Cython? Python 中 numpy.random 和 random.random 之间的性能差异 - Performance difference between numpy.random and random.random in Python Python的insert()方法与通过切片插入之间的实现和性能差异 - Implementation and performance difference between Python's insert() method and inserting by slicing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM