On 8/16/2011 7:49 PM, Seebs wrote:
On 2011-08-16, Terry Reedy<tjre...@udel.edu>  wrote:
On 8/16/2011 2:56 PM, Seebs wrote:
I wonder whether there's a way to mitigate the cost of these things by
messing with -W settings, such that runtime that wants to be fast can
omit the checks, but the default could still be to, well, prevent likely
errors.

Warning messages have a cost even if suppressed.

Yes, but is it a *significant* cost?  My assumption is that the suppression
would be of checking, not just of displaying messages.

The -W settings suppress display or printing of warnings, not their generation.

import warnings

if some_condition:
  warnings.warn(message, Warning)

The test and warn call are made regardless of disposition. Filters determine what is done with each Warning subclass. The logging module can grab them too.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to