本文共 4897 字,大约阅读时间需要 16 分钟。
The time has finally come: 2.0 is out! This is a release which took me a considerable amount of effort and careful thinking during the past 4 months as I went through a major rewrite and reorganization of both python and C extension modules. To get a sense of how much has changed you can compare the differences with old 1.2.1 version by running “hg diff -r release-1.2.1:release-2.0.0” which will produce more than 22,000 lines of output! In those 22k lines I tried to nail down all the quirks the project had accumulated since its start 4 years ago and the resulting code base is now cleaner than ever, more manageable and fully compliant with and guidelines. There were some difficult decisions because many of the changes I introduced are not backward compatible so I was concerned with the pain this may cause existing users. I kind of still am, but I’m sure the transition will be well perceived on the long run as it will result in more manageable user code. OK, enough with the preface and let’s see what changed.
时机终于到了: 2.0发行了 ! 在过去的4个月中,我经历了python和C扩展模块的重大重写和重组 ,此版本花费了我大量的精力和精力。 要了解发生了什么变化,您可以通过运行“ hg diff -r release-1.2.1:release-2.0.0”将旧版本1.2.1的差异进行比较,这将产生超过22,000行的输出! 在那22,000行中,我试图确定该项目自4年前以来积累的所有怪癖,并且所产生的代码库现在比以往更干净,更易于管理并且完全符合和准则。 做出一些困难的决定是因为我引入的许多更改都不是向后兼容的,所以我担心这可能会给现有用户带来痛苦。 我还是会的,但是我确信从长远来看,这种过渡将是可以很好理解的,因为它将导致更易于管理的用户代码。 好的,足够了序言,让我们看看发生了什么变化。
I already wrote a about what changed so I recommend you to use that as the official reference on how to port your code. Long story short:
我已经写了有关更改内容的 ,因此建议您将其用作有关如何移植代码的正式参考。 长话短说:
I’ve never been happy with . The markup language provided by Google is pretty limited, plus it’s not put under revision control. New doc is more detailed, it uses reStructuredText as the markup language, it lives in the same as psutil’s and it is hosted on the excellent readthedocs web site:
我从来都不满意 。 Google提供的标记语言非常有限,而且不受版本控制。 新文档更加详细,它使用reStructuredText作为标记语言,与psutil驻留在同一 ,并且托管在优秀的readthedocs网站上: ://psutil.readthedocs.org/
You’re now able to distinguish between logical and physical CPUs:
现在,您可以区分逻辑CPU和物理CPU:
>>> psutil.cpu_count() # logical4>>> psutil.cpu_count(logical=False) # physical cores only2
Full story is in .
完整的故事在 。
Basically this means process instances can now be checked for equality and can be used with :
基本上,这意味着现在可以检查流程实例是否相等,并且可以与 :
>>> p1 = psutil.Process()>>> p2 = psutil.Process()>>> p1 == p2True>>> set((p1, p2))set([])
Full story is in .
完整的故事在 。
翻译自:
转载地址:http://nnqwd.baihongyu.com/