Re: [Python-Dev] Add a developer mode to Python: -X dev command line option

2017年11月16日 05:07:55 -0800

2017年11月16日 13:54 GMT+01:00 Antoine Pitrou <[email protected]>:
> -Wdefault means -Wonce or -Walways? If the former, I don't expect many
> warnings to be emitted.
It's kind of funny that passing "-W default" changes the "default"
behaviour. "-W default" is documented as:
 "Explicitly request the default behavior (printing each warning
once per source line)."
https://docs.python.org/dev/using/cmdline.html#cmdoption-w
Default warnings filters in release mode:
$ python3 -c 'import pprint, warnings; pprint.pprint(warnings.filters)'
[('ignore', None, <class 'DeprecationWarning'>, None, 0),
 ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0),
 ('ignore', None, <class 'ImportWarning'>, None, 0),
 ('ignore', None, <class 'BytesWarning'>, None, 0),
 ('ignore', None, <class 'ResourceWarning'>, None, 0)]
-Wd adds the a warnings filter with the "default" action matching all
warnings (any kind, any message, any line number) if I understand
correctly:
$ python3 -Wd -c 'import pprint, warnings; pprint.pprint(warnings.filters)'
[('default',
 re.compile('', re.IGNORECASE),
 <class 'Warning'>,
 re.compile(''),
 0),
 ('ignore', None, <class 'DeprecationWarning'>, None, 0),
 ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0),
 ('ignore', None, <class 'ImportWarning'>, None, 0),
 ('ignore', None, <class 'BytesWarning'>, None, 0),
 ('ignore', None, <class 'ResourceWarning'>, None, 0)]
"default" and "once" actions are different:
default: "print the first occurrence of matching warnings for **each
location where the warning is issued**"
once: "print only the first occurrence of matching warnings,
**regardless of location**"
>> For example, on test_os, PYTHONMALLOC=debug increases the peak memory
>> usage from 10.5 MiB to 15.8 MiB: +50%.
>
> I see. For my use cases, this would be acceptable :-)
>
> But I think this should be documented, for example:
>
> """Currently, developer mode adds negligible CPU time overhead, but can
> increase memory consumption significantly if many small objects are
> allocated. This is subject to change in the future."""
+50% memory is inacceptable to develop on embedded devices, or more
generally with low level. But in that case, you are can enable options
enabled by -X dev manually, without PYTHONMALLOC=debug :-)
Ok, I will document that, I like your proposed paragraph.
Victor
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to