[Python-Dev] Re: Macro for logging

2020-10-28 Thread Serhiy Storchaka
21.10.20 15:30, Antoine Pitrou пише: > On Wed, 21 Oct 2020 14:19:37 +0200 > Marco Sulla wrote: >> If not already present, do you think it's useful to add a macro that does >> something like >> >> # ifdef Py_DEBUG >> fprintf(stderr, "%s\n", message); >> # endif > > In general, you want to do t

[Python-Dev] Re: Macro for logging

2020-10-28 Thread Marco Sulla
Thank you Victor, I know. I meant a macro in CPython. Maybe not so sane to have a unique global logger in C, as Antoine pointed out. ___ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://m

[Python-Dev] Re: Macro for logging

2020-10-26 Thread Victor Stinner
Hi, There is the __debug__ builtin variable which is equal to True by default, but is equal to False when Python is run with the -O command line option. The compiler removes dead code when -O is used. Example: $ cat x.py def func(): if __debug__: print("debug") import dis dis.dis(func) # "

[Python-Dev] Re: Macro for logging

2020-10-21 Thread Antoine Pitrou
On Wed, 21 Oct 2020 14:19:37 +0200 Marco Sulla wrote: > If not already present, do you think it's useful to add a macro that does > something like > > # ifdef Py_DEBUG > fprintf(stderr, "%s\n", message); > # endif In general, you want to do this on a per-component basis, so each C source fil