Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-06 Thread Eloi Gaudry
Sent: Tuesday, June 5, 2018 7:25:45 PM To: python-ideas@python.org Subject: Re: [Python-ideas] Runtime assertion with no overhead when not active I currently use the form and log_function( ) where is some module variable, usually "DEBUG". I do this because it i

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread MRAB
On 2018-06-05 18:25, Kyle Lahnakoski wrote: I currently use the form     and log_function( ) where is some module variable, usually "DEBUG".  I do this because it is one line, and it ensures the log_function parameters are not evaluated. You'd get the same result with: if :

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread Kyle Lahnakoski
I currently use the form     and log_function( ) where is some module variable, usually "DEBUG".  I do this because it is one line, and it ensures the log_function parameters are not evaluated. *IF* runtime assertions had a switch so they have no overhead when not active, how much faster

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread Eloi Gaudry
, 2018 3:33:30 PM To: python-ideas@python.org Subject: Re: [Python-ideas] Runtime assertion with no overhead when not active Maybe somebody already answered this, but what's the difference between this and the keyword "assert", which basically can be stripped of using "python -o"

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-06-05 Thread Michel Desmoulin
Maybe somebody already answered this, but what's the difference between this and the keyword "assert", which basically can be stripped of using "python -o" ? Le 05/05/2018 à 10:04, Eloi Gaudry a écrit : > > Hi folks, > > > I intend to add a runtime assertion feature in python. Before >

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-17 Thread Steven D'Aprano
On Thu, May 17, 2018 at 07:46:41AM +, Eloi Gaudry wrote: > On Thu, 2018-05-17 at 03:09 +1000, Steven D'Aprano wrote: > I proposed to have several ways to set it (see previous answers) : one > would be extension based and the other would rely on having a builtin > value that one would be able

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-17 Thread Chris Angelico
On Thu, May 17, 2018 at 5:46 PM, Eloi Gaudry wrote: >> But the most important reason is that I'm not really interested in >> adding a new keyword for this. I would much prefer to explore ways >> to >> allow ordinary functions to receive arguments and be able to delay >>

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-17 Thread Eloi Gaudry
On Thu, 2018-05-17 at 03:09 +1000, Steven D'Aprano wrote: > On Wed, May 16, 2018 at 01:27:50PM +, Eloi Gaudry wrote: > > On Wed, 2018-05-16 at 21:15 +1000, Steven D'Aprano wrote: > > > On Wed, May 16, 2018 at 08:29:00AM +, Eloi Gaudry wrote: > > > > Is there some interest in the proposal

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-16 Thread Steven D'Aprano
On Wed, May 16, 2018 at 01:27:50PM +, Eloi Gaudry wrote: > On Wed, 2018-05-16 at 21:15 +1000, Steven D'Aprano wrote: > > On Wed, May 16, 2018 at 08:29:00AM +, Eloi Gaudry wrote: > > > Is there some interest in the proposal or should I finally close > > > this > > > thread ? > > > > I'm

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-16 Thread Eloi Gaudry
On Wed, 2018-05-16 at 21:15 +1000, Steven D'Aprano wrote: > On Wed, May 16, 2018 at 08:29:00AM +, Eloi Gaudry wrote: > > Is there some interest in the proposal or should I finally close > > this > > thread ? > > I'm definitely interested in the concept, not the suggested syntax > or  >

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-16 Thread Steven D'Aprano
On Wed, May 16, 2018 at 08:29:00AM +, Eloi Gaudry wrote: > Is there some interest in the proposal or should I finally close this > thread ? I'm definitely interested in the concept, not the suggested syntax or semantics. -- Steve ___

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-16 Thread Eloi Gaudry
Is there some interest in the proposal or should I finally close this thread ? Thanks for your feedback, Eloi > ___ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct:

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-10 Thread Steven D'Aprano
On Thu, May 10, 2018 at 08:55:44AM +0100, Barry Scott wrote: > This idea requires the same sort of machinery in python that I was > hoping for to implement the short circuit logging. I'm working on an idea for delayed evaluation of expressions, and I think your idea of logging below would make

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-10 Thread Nick Coghlan
On 10 May 2018 at 17:55, Barry Scott wrote: > On 7 May 2018, at 18:52, Guido van Rossum wrote: > > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka > wrote: > >> I just don't understand why you need a new keyword for writing

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-10 Thread Barry Scott
> On 7 May 2018, at 18:52, Guido van Rossum wrote: > > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka > wrote: > I just don't understand why you need a new keyword for writing runtime checks. > > Oh, that's pretty clear.

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
control is indeed by the consumer/the extension? -Original Message- From: Python-ideas <python-ideas-bounces+eloi.gaudry=fft...@python.org> On Behalf Of Chris Angelico Sent: Tuesday, May 8, 2018 7:38 PM To: python-ideas@python.org Subject: Re: [Python-ideas] Runtime assert

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 5:27 AM, Eloi Gaudry wrote: > My choice of words might not be the best, yes. > I do see to different meanings and/or context for the historical assert and > the one I propose: > > 1/ > the first one would be something saying that, as a developer, when

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Chris Angelico
On Wed, May 9, 2018 at 1:51 AM, Eloi Gaudry wrote: > I think that is a difference between: > - the current 'assert' which usage seems (to me) to focus on > development correctness (I think of it as the C-assert enabled in any C > program in debug build ) > - the runtime_assert

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
On Wed, 2018-05-09 at 01:34 +1000, Steven D'Aprano wrote: > On Tue, May 08, 2018 at 07:37:55AM +, Eloi Gaudry wrote: > > > * debug assert, for helping developing a new features, used with > > debug- > > builds > > * runtime assert, for ensuring correctness and/or diagnosing issue > > with > >

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Serhiy Storchaka
08.05.18 18:34, Steven D'Aprano пише: I don't even know which builds of Python I'm running. My *guess* is that the OS-provided Python is probably a non-debug build, and the ones I've compiled from source will be whatever the default build settings are, but I don't know what that is or how to

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
On Tue, 2018-05-08 at 09:58 -0400, Eric V. Smith wrote: > I think what's confusing to me (and maybe others) is that we haven't  > seen your vision on how this would look in Python code. > > An example that would throw runtime assertions and the same example  > where it wouldn't (after a global

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Serhiy Storchaka
07.05.18 20:52, Guido van Rossum пише: He basically wants a macro so that   runtime_assert() expands to   if and ():   raise AssertionError In Lisp this would be easy. :-) Python is not Lisp (still). But there is the MacroPy project. And at end you always can use an external tool

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Steven D'Aprano
On Tue, May 08, 2018 at 09:58:51AM -0400, Eric V. Smith wrote: > I think what's confusing to me (and maybe others) is that we haven't > seen your vision on how this would look in Python code. > > An example that would throw runtime assertions and the same example > where it wouldn't (after a

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Steven D'Aprano
On Tue, May 08, 2018 at 07:37:55AM +, Eloi Gaudry wrote: > * debug assert, for helping developing a new features, used with debug- > builds > * runtime assert, for ensuring correctness and/or diagnosing issue with > production/release-builds on-site. I don't think that is a useful

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
On Tue, 2018-05-08 at 07:37 -0700, Guido van Rossum wrote: > > > In Lisp this would be easy. :-) > > > > and he already has a diff ready for review if needed (basically > > very > > similar to the current 'assert' implementation :) > > That seems premature. There is not even a hint of agreement

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Guido van Rossum
On Tue, May 8, 2018 at 12:29 AM, Eloi Gaudry wrote: > On Mon, 2018-05-07 at 10:52 -0700, Guido van Rossum wrote: > > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka > > wrote: > > > I just don't understand why you need a new keyword for writing > > >

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
On Tue, 2018-05-08 at 09:35 -0400, Eric V. Smith wrote: > On 5/8/2018 3:37 AM, Eloi Gaudry wrote: > > On Mon, 2018-05-07 at 16:56 +, Brett Cannon wrote: > > > > > > My question is how is this different to running with -O which > > > leaves > > > the assert statement out of the bytecode and so

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eric V. Smith
On 5/8/2018 9:50 AM, Eloi Gaudry wrote: On Tue, 2018-05-08 at 09:35 -0400, Eric V. Smith wrote: On 5/8/2018 3:37 AM, Eloi Gaudry wrote: On Mon, 2018-05-07 at 16:56 +, Brett Cannon wrote: My question is how is this different to running with -O which leaves the assert statement out of the

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eric V. Smith
On 5/8/2018 3:37 AM, Eloi Gaudry wrote: On Mon, 2018-05-07 at 16:56 +, Brett Cannon wrote: My question is how is this different to running with -O which leaves the assert statement out of the bytecode and so you avoid any run- time cost of the statement entirely? Not so much different,

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
On Mon, 2018-05-07 at 16:56 +, Brett Cannon wrote: > > My question is how is this different to running with -O which leaves > the assert statement out of the bytecode and so you avoid any run- > time cost of the statement entirely?  Not so much different, except that: - the switch won't need

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-08 Thread Eloi Gaudry
On Mon, 2018-05-07 at 10:52 -0700, Guido van Rossum wrote: > On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka > wrote: > > I just don't understand why you need a new keyword for writing > > runtime checks. > > Oh, that's pretty clear. The OP wants to be able to turn these

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-07 Thread Guido van Rossum
On Mon, May 7, 2018 at 6:24 AM, Serhiy Storchaka wrote: > I just don't understand why you need a new keyword for writing runtime > checks. > Oh, that's pretty clear. The OP wants to be able to turn these checks off with some flag he can set/clear at runtime, and when it's

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-07 Thread Brett Cannon
On Mon, 7 May 2018 at 06:28 Serhiy Storchaka wrote: > 07.05.18 12:58, Eloi Gaudry пише: > > I didn't mean to replace the current (debug) assert but I wanted to add > > another one that would allow to be switch on or off on production builds. > > > > The need for a new

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-07 Thread Serhiy Storchaka
07.05.18 12:58, Eloi Gaudry пише: I didn't mean to replace the current (debug) assert but I wanted to add another one that would allow to be switch on or off on production builds. The need for a new keyword (not syntax) comes from this difference.  I cannot think of another example that

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-07 Thread Eloi Gaudry
On Sun, 2018-05-06 at 01:30 +1000, Steven D'Aprano wrote: > On Sat, May 05, 2018 at 08:04:45AM +, Eloi Gaudry wrote: > > > Hi folks, > > I intend to add a runtime assertion feature in python. > > I'm very interested in this idea, but I'm afraid your draft PEP > isn't  > very clear about this

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-07 Thread Eloi Gaudry
, 2018 17:44 To: python-ideas@python.org Subject: Re: [Python-ideas] Runtime assertion with no overhead when not active 05.05.18 18:04, Eloi Gaudry пише: > By 'self-contained', I meant that using the assert keyword and its > expression is sufficient. An inline assertive expression as the one y

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-05 Thread Serhiy Storchaka
05.05.18 18:04, Eloi Gaudry пише: By 'self-contained', I meant that using the assert keyword and its expression is sufficient. An inline assertive expression as the one you describe does not fulfill this assert requirement. Sufficient for what? And why writing with using the existing syntax

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-05 Thread Steven D'Aprano
On Sat, May 05, 2018 at 08:04:45AM +, Eloi Gaudry wrote: > Hi folks, > I intend to add a runtime assertion feature in python. I'm very interested in this idea, but I'm afraid your draft PEP isn't very clear about this feature. Comments below. > Rationale > There is no runtime assert

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-05 Thread Eloi Gaudry
/on at runtime. The syntax example I gave illustrated what I meant by syntax aware. De : Serhiy Storchaka Envoyé : samedi 5 mai à 15:10 Objet : Re: [Python-ideas] Runtime assertion with no overhead when not active À : python-ideas@python.org 05.05.18 15:54, Eloi Gaudry пише: > I meant avoid

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-05 Thread Serhiy Storchaka
05.05.18 15:54, Eloi Gaudry пише: I meant avoiding the overhead of the expression evaluation enclosed in the assert itself, not the active/disabled state (that comes at virtually no cost). ex: runtime_assert( { i:None for i in range( 1000 ) } ) By using the syntax you describe ('boolean

Re: [Python-ideas] Runtime assertion with no overhead when not active

2018-05-05 Thread Eloi Gaudry
-Original Message- From: Python-ideas <python-ideas-bounces+eloi.gaudry=fft...@python.org> On Behalf Of Serhiy Storchaka Sent: Saturday, May 5, 2018 2:05 PM To: python-ideas@python.org Subject: Re: [Python-ideas] Runtime assertion with no overhead when not active 05.05.18 11:04, Eloi