New submission from STINNER Victor <victor.stin...@gmail.com>: When Python 2.7 is built in debug mode, it displays the total number of references when the program finishes or after each statement in the interactive interpreter.
Example: haypo@selma$ ./python Python 2.7.14+ (heads/2.7:cc4b6f1c62, Oct 9 2017, 15:30:11) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 1+1 2 [45025 refs] >>> 2+2 4 [45025 refs] >>> [45025 refs] [21655 refs] While I'm Python core developer working on reference leaks for years, I *never* used this value. I only use "python -m test -R 3:3 test_xxx" to track reference leaks. I really liked Python 3.4 which made this option an opt-in, python3 -X showrefcount: bpo-17323 (commit 1f8898a5916b942c86ee8716c37d2db388e7bf2f). I propose to change Python 2.7 behaviour to not print this value by default, but add a new PYTHONSHOWREFCOUNT environment variable to display it. The value is displayed if PYTHONSHOWREFCOUNT is set. Other similar existing variables: * PYTHONTHREADDEBUG * PYTHONDUMPREFS * PYTHONMALLOCSTATS https://docs.python.org/2.7/using/cmdline.html#debug-mode-variables I prefer to add a new environment style rather than adding a new -X command line option. IMHO an environment variable is less intrusive. For example, older Python 2.7 versions completely ignore unknown environment variables, whereas "python2.7 -X showrefcount ..." currently logs the "-X is reserved for implementation-specific arguments" message into stderr. Attached PR adds PYTHONSHOWREFCOUNT. ---------- messages: 303952 nosy: haypo priority: normal severity: normal status: open title: [2.7] Add PYTHONSHOWREFCOUNT environment variable to Python 2.7 versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31733> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com