giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.08k stars 1.37k forks source link

Speedup process iter #2404

Closed giampaolo closed 2 months ago

giampaolo commented 2 months ago

Summary

Description

No longer make process_iter() check whether PID has been reused. This makes it around 20x times faster on Linux. Also changed Process.is_running() so that it will automatically remove the reused PID from process_iter() internal cache. In addition, also add a new process_iter.cache_clear() API.