[New-bugs-announce] [issue39489] Remove COUNT_ALLOCS special build

STINNER Victor report at bugs.python.org
Wed Jan 29 13:16:16 EST 2020

New submission from STINNER Victor <vstinner at 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.)"


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

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list