[New-bugs-announce] [issue37406] Disable runtime checks in release mode

STINNER Victor report at bugs.python.org
Tue Jun 25 19:16:31 EDT 2019


New submission from STINNER Victor <vstinner at redhat.com>:

A Python debug build is ABI compatible with a Python release build since Python 3.8 on most platforms (except Windows, Cygwin and Android):
https://docs.python.org/3.8/whatsnew/3.8.html#debug-build-uses-the-same-abi-as-release-build

It should now be way easier to debug an application with a debug build.

I propose to remove runtime debug checks in release mode. assert() is already widely used in the C code base, but there are many runtime checks using PyErr_BadInternalCall() or PyErr_BadArgument. Example:

Py_ssize_t
PyUnicode_GetLength(PyObject *unicode)
{
    if (!PyUnicode_Check(unicode)) {
        PyErr_BadArgument();
        return -1;
    }
    if (PyUnicode_READY(unicode) == -1)
        return -1;
    return PyUnicode_GET_LENGTH(unicode);
}

Attached PR removes these checks when Python is compiled in release mode: when Py_DEBUG is not defined.

Even if I marked this issue as "performance", I don't expect a significant speedup.

----------
components: Interpreter Core
messages: 346570
nosy: vstinner
priority: normal
severity: normal
status: open
title: Disable runtime checks in release mode
type: performance
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37406>
_______________________________________


More information about the New-bugs-announce mailing list