A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-August/081965.html below:

[Python-Dev] performance

[Python-Dev] performance [Python-Dev] performanceSteven D'Aprano steve at pearwood.info
Mon Aug 25 01:54:48 CEST 2008
On Mon, 25 Aug 2008 05:04:16 am Antoine Pitrou wrote:
> > >         CompareFloatsIntegers:    274ms    274ms    0.30us  
> > >  0.630ms
> >
> > Much slower, but probably due to switch from int -> long.  There
> > could be potential for optimizing this case.
>
> Well honestly you don't often compare different types. I think the
> most common exception to this rule would be None vs. non-None.


Surely the most common None vs non-None comparison would be the "is" 
operator, which I hope remains fast.

I don't know about other people, but I often compare floats with ints. 
Here's a contrived example:

x = some_float()
if x == -1:
    return -2
else:
    return (x**2-1)/(x+1)


I suppose it's no hardship to start writing float literals instead of 
int literals, if needed.


-- 
Steven
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4