[issue37406] Disable runtime checks in release mode

2019-07-16 Thread STINNER Victor


STINNER Victor  added the comment:

I didn't find time to write a proper a rationale for this change, and I will 
not be available next weeks. So I prefer to close this issue. I may reopen it 
later once I have a strong rationale :-) In the meanwhile, have a look at the 
new PyHandle API idea which will start without sanity check in release mode 
since day 1 :-)
https://github.com/pyhandle/pyhandle/

--
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37406] Disable runtime checks in release mode

2019-07-01 Thread STINNER Victor


STINNER Victor  added the comment:

FYI I'm finishing an article to explain the problem that I am trying to solve 
here. Sorry for the delay, I will reply later :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37406] Disable runtime checks in release mode

2019-07-01 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> Python's exception mechanism is a much better way to signal and handle such 
> errors at the application level.

I disagree. There is a difference between exceptions which are possible in 
normal usage of the code and real bugs, which shouldn't ever happen. A NULL 
argument to a C API function is not an ordinary exception, it's a real bug. 
Even if we raise a Python exception for that, it should never be handled in a 
try/exception block like an ordinary exception.

> Using assert() in C is a pretty bad alternative, since this crashes the whole 
> process.

I *prefer* debugging an assert() failure (which is pretty easy with a decent 
debugger) rather than debugging a Python exception raised from C (which 
typically does NOT give a useful traceback).

--
nosy: +jdemeyer

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37406] Disable runtime checks in release mode

2019-06-26 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I think that the public C API should have runtime checks for its arguments, 
except performance sensitive functions and macros (like PyTuple_GET_ITEM). The 
internal C API can use just asserts.

I have a work-in-progress patch which adds tests for the public C API, 
including calls with invalid arguments.

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37406] Disable runtime checks in release mode

2019-06-26 Thread Marc-Andre Lemburg


Marc-Andre Lemburg  added the comment:

Given that extensions call these APIs, I find it highly risky to
disable these checks in any version of the Python runtime and
am -1 on such a change.

Using assert() in C is a pretty bad alternative, since this crashes
the whole process. It should really only be used where no other
means of error handling are possible. Python's exception mechanism
is a much better way to signal and handle such errors at the
application level.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Jun 26 2019)
>>> Python Projects, Coaching and Consulting ...  http://www.egenix.com/
>>> Python Database Interfaces ...   http://products.egenix.com/
>>> Plone/Zope Database Interfaces ...   http://zope.egenix.com/


::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/
  http://www.malemburg.com/

--
nosy: +lemburg
title: Disable debug runtime checks in release mode -> Disable runtime checks 
in release mode

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37406] Disable runtime checks in release mode

2019-06-25 Thread STINNER Victor


New submission from STINNER Victor :

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com