Announcing psutil 2.0

psutil 2.0 is out. This is a major rewrite and reorganization of both the Python and C extension modules. It costed me four months of work and more than 22,000 lines (the diff against old 1.2.1). Many of the changes are not backward compatible; I’m sure this will cause some pain, but I think it’s for the better and needed to be done.

API changes

I already wrote a detailed blog post about this, so use that as the official reference on how to port your code.

RST documentation

I’ve never been happy with the old doc hosted on Google Code. The markup language provided by Google is pretty limited, plus it’s not under revision control. The new doc is more detailed, uses reStructuredText as the markup language, lives in the same code repository as psutil, and is hosted on the excellent Read the Docs: http://psutil.readthedocs.org/

Physical CPUs count

You’re now able to distinguish between logical and physical CPUs. The full story is in #427.

>>> psutil.cpu_count()  # logical
4
>>> psutil.cpu_count(logical=False)  # physical cores only
2

Process instances are hashable

psutil.Process instances can now be compared for equality and used in sets and dicts. The most useful application is diffing process snapshots:

>>> before = set(psutil.process_iter())
>>> # ... some time passes ...
>>> after = set(psutil.process_iter())
>>> new_procs = after - before  # processes spawned in between

Equality is not just PID-based. It also includes the process creation time, so a Process whose PID got reused by the kernel won’t be mistaken for the original. The full story is in #452.

Speedups

Other improvements and bugfixes

See the changelog for a full list of changes.