context manager based alternative to Re: Proposal: === and !===

Cameron Simpson cs at zip.com.au
Fri Jul 11 18:42:44 EDT 2014


On 10Jul2014 17:34, Ethan Furman <ethan at stoneleaf.us> wrote:
>On 07/10/2014 05:20 PM, Cameron Simpson wrote:
>>Here's an alternative proposal that doesn't involve a new operator.
>[snip float-context manager stuff]
>
>Decimal has a context manager like that already (I don't know if it 
>supports allowing NaNs to equal each other, though).

Interesting. I did not know that. [...] Ah, 9.4.3 Context Objects. Cool.

>Rather than adding the whole thing to float, perhaps extending Decimal's 
>context with that option is a possible route.

The OP needed to work with floats. The data storage systems he was using stored 
IEEE floats IIRC, so Decimal may not be suitable and possibly has performance 
effects too - dunno.

I would think he'd need something implemented in the float type.

Cheers,
Cameron Simpson <cs at zip.com.au>

Nothing is impossible for the man who doesn't have to do it.



More information about the Python-list mailing list