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
As of right now we have different process methods which are returning a list:
Process.get_open_files()
Process.get_connections()
Process.get_children()
Process.get_threads()
I think *at least* the first 2 should return an iterator instead.
That would be particularly useful for get_open_files() and get_connections()
since they can produce hundreds of results.
Users using those methods in a for loop won't suffer any code breakage.
Others will be bitten though, so maybe it makes sense to schedule this change
for a major release (1.0.0 maybe, the project is mature enough to get there
after all).
I don't fully agree. Not being able to index the return value of the methods
would be annoying to me. I would then need to do
>>> [p for p in Process.get_children()][0]
instead of just
>>> Process.get_children()[0]
Are you planning to change the underling C implementation for these methods?
Right now the list is being built in C code, so there would be very little
benefit to turning these into iterators at the Python API wrapper level.
Can we make a good enough case for a performance or functionality improvement
by making these into iterators that it's worth breaking compatibility with the
previous versions?
> Are you planning to change the underling C implementation for these methods?
Yes: http://docs.python.org/c-api/gen.html Building the whole list in C and
then yield-ify it in python would be useless.
> Can we make a good enough case for a performance or functionality improvement
> by making these into iterators that it's worth breaking compatibility with
> the previous versions?
Yeah, I suppose it makes sense to make a benchmark first to figure out whether
this actually worths the effort.
From g.rodola on January 19, 2012 14:47:03
Original issue: http://code.google.com/p/psutil/issues/detail?id=243
The text was updated successfully, but these errors were encountered: