You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
>>> p1 = psutil.Process(32141)
>>> p2 = psutil.Process(32141)
>>> set([p1, p2])
set([<psutil.Process(pid=32141, name='python') at 140160404497552>,
<psutil.Process(pid=32141, name='python') at 140160438974928>])
>>>
It would be nice if the set could recognize the same Process instance based on
its PID and remove duplicates.
In order to do that the Process class should override __eq__ and __hash__
special methods.
Long ago we attempted to introduce __eq__ but we ended up regretting it because
introducing advanced logic in it may lead to unexpected drawbacks:
https://code.google.com/p/psutil/issues/detail?id=211 I want to take that back
now and make __eq__ just compare process pid (as opposed to pid + creation
time) and consider this one of those cases where practicality beats purity.
From g.rodola on December 03, 2013 23:57:30
Original issue: http://code.google.com/p/psutil/issues/detail?id=452
The text was updated successfully, but these errors were encountered: