New submission from STINNER Victor <vstin...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue37406>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to