[Python-Dev] Not-a-Number (was PyObject_RichCompareBool identity shortcut)

Terry Reedy tjreedy at udel.edu
Sun May 1 20:45:06 CEST 2011

On 5/1/2011 7:27 AM, Nick Coghlan wrote:

> However, I did find Terry's suggestion of using the warnings module to
> report some of the floating point corner cases that currently silently
> produce unexpected results to be an interesting one. If those
> operations issued a FloatWarning, then users could either silence them
> or turn them into errors as desired.

I would like to take credit for that, but I was actually seconding 
Alexander's insight and idea. I may have added the specific name after 
looking at the currently list and seeing UnicodeWarning and 
BytesWarning, so why not a FloatWarning. I did read the warnings doc 
more carefully to verify that it would really put the user in control, 
which was apparently the intent of the committee.

I am not sure whether FloatWarnings should ignored or printed by 
default. Ignored would, I guess, match current behavior, unless 
something else is changed as part of a more extensive overhaul. -f and 
-ff are available to turn ignored FloatWarning into print or raise 
exception, as with BytesWarning. I suspect that these would get at lease 
as much usage as -b and -bb.

So I see 4 questions:
1. Add FloatWarning?
2. If yes, default disposition?
3. Add command line options?
4. Use the addition of FloatWarning as an opportunity to change other 
defaults, given that user will have more options?

Terry Jan Reedy

More information about the Python-Dev mailing list