New submission from STINNER Victor <vstin...@python.org>:

Python has a COUNT_ALLOCS special build which adds sys.getcounts() function and 
shows statistics on Python types at exit if -X showalloccount command line 
option is used.

I never ever used this feature and I don't know anyone using it.

But "#ifdef COUNT_ALLOCS" code is scattered all around the code. It requires 
maintenance. I propose to remove the code to ease maintenance.

Attached PR shows how much code is requires to support this special build.

There are now more advanced tools to have similar features:

* tracemalloc can be used to track memory leaks
* gc.getobjects() can be called frequently to compute statistics on Python types
* There are many tools built around gc.getobjects()

The previous large change related to COUNT_ALLOCS was done in Python 3.6 by 
bpo-23034:

"The output of a special Python build with defined COUNT_ALLOCS, 
SHOW_ALLOC_COUNT or SHOW_TRACK_COUNT macros is now off by default. It can be 
re-enabled using the -X showalloccount option. It now outputs to stderr instead 
of stdout. (Contributed by Serhiy Storchaka in bpo-23034.)"

https://docs.python.org/dev/whatsnew/3.6.html#changes-in-python-command-behavior

----------
components: Build
messages: 360978
nosy: vstinner
priority: normal
severity: normal
status: open
title: Remove COUNT_ALLOCS special build
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39489>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to