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.
API changes
I already wrote a detailed blog post about what changed so I recommend you to use that as the official reference on how to port your code. Long story short:- all get_* prefixes for functions and methods are gone, e.g.:
- psutil.get_boot_time() -> psutil.boot_time()
- psutil.Process.get_cpu_percent() -> psutil.Process.cpu_percent()
- all set_* prefixes for Process methods are gone and were unified in a single method which can be used for both getting and setting, e.g:
- psutil.Process.set_nice(value) -> psutil.Process.nice(value)
- Process properties were turned into methods, e.g.:
- psutil.Process.cmdline -> psutil.Process.cmdline()
- module level constants (BOOT_TIME, NUM_CPUS, TOTAL_PHYMEM) were turned into functions (psutil.boot_time(), psutil.cpu_count(), psutil.virtual_memory().total)
- all the old names are still there but will raise a DeprecationWarning
- you will have to explicitly enable warnings via "python -Wd foo.py" though
- the only fully incompatible change is represented by the Process properties which are now methods
RST documentation
I've never been happy with old doc hosted on Google Code. 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 code repository as psutil's and it is hosted on the excellent readthedocs web site: http://psutil.readthedocs.org/Physical CPUs count
You're now able to distinguish between logical and physical CPUs:>>> psutil.cpu_count() # logical 4 >>> psutil.cpu_count(logical=False) # physical cores only 2Full story is in issue 427.
Process instances are hashable
Basically this means process instances can now be checked for equality and can be used with set()s:>>> p1 = psutil.Process() >>> p2 = psutil.Process() >>> p1 == p2 True >>> set((p1, p2)) set([<psutil.Process(pid=8217, name='python') at 140007043550608>])Full story is in issue 452.
Speedups
- #477: process cpu_percent() is about 30% faster.
- #478: (Linux) almost all APIs are about 30% faster on Python 3.X.
Other improvements and bugfixes
- #424: Windows installers for Python 3.X 64-bit
- #447: psutil.wait_procs() timeout parameter is now optional.
- #459: a Makefile is now available for running tests and other repetitive tasks (also on Windows)
- #463: timeout parameter of cpu_percent* functions default to 0.0 because it was a common trap to introduce slowdowns.
- #340: (Windows) process open_files() no longer hangs.
- #448: (Windows) fixed a memory leak affecting children() and ppid() methods.
- #461: namedtuples are now pickle-able.
- #474: (Windows) Process.cpu_percent() is no longer capped at 100%
List of all changes is available here.
OK, that's all folks. I hope you will enjoy this new version and report your feedback.
OK, that's all folks. I hope you will enjoy this new version and report your feedback.