Ezio Melotti added the comment:
Here's a proof of concept that defines a new _print_total_refs() function and
calls it through the PRINT_TOTAL_REFS macro, disables printing the refs by
default, and adds a "-X showrefcount" option to reenable it. This can also be
achieved at runtime by adding/removing 'showrefcount' from the sys._xoptions
dict.
Things that should be done/decided before the final version:
1) the function and/or prototype should probably be moved to a better place;
2) the 'showrefcount' name sounds ok to me, but I'm open to suggestions if you
can come up with something better;
3) the function could do the equivalent of "if
sys._xoptions.get('showrefcount', False):" instead of "if 'showrefcount' in
sys._xoptions:";
4) now that this can be enabled/disabled at runtime, we might make it
available to non-debug builds too (unless there are other negative
side-effects);
----------
keywords: +patch
Added file: http://bugs.python.org/file29331/issue17323.diff
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue17323>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com