msg174060 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-10-28 17:30 |
This patch adds a function named gc.get_stats() which returns a list of dictionaries containing per-generation statistics: >>> import pprint, gc >>> pprint.pprint(gc.get_stats()) [{'collected': 0, 'collections': 12, 'uncollectable': 0}, {'collected': 0, 'collections': 1, 'uncollectable': 0}, {'collected': 0, 'collections': 0, 'uncollectable': 0}] |
|
|
msg174062 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2012-10-28 17:42 |
What are the possible performance implications of the statistics? |
|
|
msg174063 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-10-28 17:44 |
You mean negative implications? None :-) |
|
|
msg174067 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2012-10-28 18:18 |
Why dictionaries and not struct sequences? |
|
|
msg174068 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2012-10-28 18:30 |
Oh, I understand. GC callbacks receive a dict. For avoid confusion with gc.DEBUG_STATS and to conform with callbacks argument name, may be better to name this function as gc.get_infos([generation])? |
|
|
msg174069 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2012-10-28 18:32 |
I.e. gc.get_info([generation]). Returns the info for specified generation or total if the parameter omitted. |
|
|
msg174070 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-10-28 18:39 |
> Why dictionaries and not struct sequences? Because it's much simpler like that. > For avoid confusion with gc.DEBUG_STATS and to conform with callbacks > argument name, may be better to name this function as > gc.get_infos([generation])? Well, this is really about statistics, not general information. Furthermore, it is not related to the callbacks functionality. As for the generation parameter, I don't think it's useful: the result list is only 3 elements long. |
|
|
msg174230 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2012-10-30 21:46 |
New changeset 43d87cdf9457 by Antoine Pitrou in branch 'default': Issue #16351: New function gc.get_stats() returns per-generation collection statistics. http://hg.python.org/cpython/rev/43d87cdf9457 |
|
|
msg174231 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2012-10-30 21:47 |
Now committed. |
|
|
msg174236 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2012-10-30 22:56 |
> Because it's much simpler like that. Well, I wrote a patch with structure sequences, it is really much more expansive. I have some comments. 1. You can allocate list of NUM_GENERATIONS elements and then use PyList_SET_ITEM(result, i, stat). This is 4 lines shorter. 2. And may be return the tuple? get_count() and get_threshold() return tuples. 3. You forgot to add get_stats() to the module docstring. |
|
|
msg206958 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2013-12-26 20:12 |
New changeset 17bd04fbf3d3 by R David Murray in branch 'default': whatsnew for gc.get_stats, plus doc tweaks. http://hg.python.org/cpython/rev/17bd04fbf3d3 |
|
|