From 7e160ce356036bccda2608d9ee10bfe276dfa97a Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 3 Jul 2016 21:03:53 +0300 Subject: Issue #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. --- Doc/using/cmdline.rst | 5 +++++ Doc/whatsnew/3.6.rst | 10 ++++++++++ Misc/NEWS | 5 +++++ Objects/listobject.c | 10 ++++++++++ Objects/object.c | 9 +++++++++ Objects/tupleobject.c | 10 ++++++++++ Python/pylifecycle.c | 2 +- 7 files changed, 50 insertions(+), 1 deletion(-) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 49fe3a0..905f14d 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -397,6 +397,8 @@ Miscellaneous options stored in a traceback of a trace. Use ``-X tracemalloc=NFRAME`` to start tracing with a traceback limit of *NFRAME* frames. See the :func:`tracemalloc.start` for more information. + * ``-X showalloccount`` to enable the output of the total count of allocated + objects for each type (only works when built with ``COUNT_ALLOCS`` defined); It also allows passing arbitrary values and retrieving them through the :data:`sys._xoptions` dictionary. @@ -410,6 +412,9 @@ Miscellaneous options .. versionadded:: 3.4 The ``-X showrefcount`` and ``-X tracemalloc`` options. + .. versionadded:: 3.6 + The ``-X showalloccount`` option. + Options you shouldn't use ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/Doc/whatsnew/3.6.rst b/Doc/whatsnew/3.6.rst index 21e887f..1550eef 100644 --- a/Doc/whatsnew/3.6.rst +++ b/Doc/whatsnew/3.6.rst @@ -646,6 +646,16 @@ Porting to Python 3.6 This section lists previously described changes and other bugfixes that may require changes to your code. +Changes in 'python' Command Behavior +------------------------------------ + +* 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 :issue:`23034`.) + + Changes in the Python API ------------------------- diff --git a/Misc/NEWS b/Misc/NEWS index 014ac54..c9a78d0 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,11 @@ What's New in Python 3.6.0 alpha 3 Core and Builtins ----------------- +- Issue #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. + - Issue #27443: __length_hint__() of bytearray itearator no longer return negative integer for resized bytearray. diff --git a/Objects/listobject.c b/Objects/listobject.c index 6e2d026..ddc0fee 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -82,6 +82,16 @@ static size_t count_reuse = 0; static void show_alloc(void) { + PyObject *xoptions, *value; + _Py_IDENTIFIER(showalloccount); + + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + value = _PyDict_GetItemId(xoptions, &PyId_showalloccount); + if (value != Py_True) + return; + fprintf(stderr, "List allocations: %" PY_FORMAT_SIZE_T "d\n", count_alloc); fprintf(stderr, "List reuse through freelist: %" PY_FORMAT_SIZE_T diff --git a/Objects/object.c b/Objects/object.c index c83c8ec..559794f 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -109,6 +109,15 @@ void dump_counts(FILE* f) { PyTypeObject *tp; + PyObject *xoptions, *value; + _Py_IDENTIFIER(showalloccount); + + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + value = _PyDict_GetItemId(xoptions, &PyId_showalloccount); + if (value != Py_True) + return; for (tp = type_list; tp; tp = tp->tp_next) fprintf(f, "%s alloc'd: %" PY_FORMAT_SIZE_T "d, " diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index a7774e2..1b41258 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -36,6 +36,16 @@ static Py_ssize_t count_tracked = 0; static void show_track(void) { + PyObject *xoptions, *value; + _Py_IDENTIFIER(showalloccount); + + xoptions = PySys_GetXOptions(); + if (xoptions == NULL) + return; + value = _PyDict_GetItemId(xoptions, &PyId_showalloccount); + if (value != Py_True) + return; + fprintf(stderr, "Tuples created: %" PY_FORMAT_SIZE_T "d\n", count_tracked + count_untracked); fprintf(stderr, "Tuples tracked by the GC: %" PY_FORMAT_SIZE_T diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 72a00e6..2d2dcba 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -626,7 +626,7 @@ Py_FinalizeEx(void) /* Debugging stuff */ #ifdef COUNT_ALLOCS - dump_counts(stdout); + dump_counts(stderr); #endif /* dump hash stats */ _PyHash_Fini(); -- cgit v0.12 '>bug_3092089 Tcl is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.
summaryrefslogtreecommitdiffstats
path: root/tests/incr.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2006-03-08 16:07:42 (GMT)
committerdgp <dgp@users.sourceforge.net>2006-03-08 16:07:42 (GMT)
commit9dcbe336bddd91bb7fab7be8e33ce7fed7f229ce (patch)
treea3b89f3d8743fcc549b1179e0277156166206aff /tests/incr.test
parent989e6a53bd54006ab5d9e15bb79f67fa2e7ece22 (diff)
downloadtcl-9dcbe336bddd91bb7fab7be8e33ce7fed7f229ce.zip
tcl-9dcbe336bddd91bb7fab7be8e33ce7fed7f229ce.tar.gz
tcl-9dcbe336bddd91bb7fab7be8e33ce7fed7f229ce.tar.bz2
* generic/tclExecute.c: Complete missing bit of TIP 215 implementation
* tests/incr.test: