On Thu, May 17, 2018 at 07:46:41AM +0000, 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 to change using a set function of the
> python core.

Sorry, I had forgetten the extension answer:

    Include/pydebug.h : int Py_RuntimeAssertFlag = 1;
    Your_extension/main.c : SetFlag(Py_RuntimeAssertFlag);

and I had missed your answer to have a builtin.

In any case, I don't think that having only a single flag for the entire 
Python application is sufficiently useful to bother with this. At the 
*absolute least* I would expect individual modules to be able to 
independently enable or disable their own "runtime assertions".

 
> What would then be solution for implementing the runtime_assert with
> the current python api ? A lambda ?

Earlier in this thread I mentioned that I had a few thoughts on that, 
and I was exploring those ideas. I asked for anyone interested to 
contact me off list.

Basically I am looking at how we could get delayed evaluation of 
expressions, which has a number of good use-cases. (So far I have four: 
this is only one of them.) And yes, wrapping the expression in a 
function (lambda) seems like the most promising approach.


 
-- 
Steve
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to