Elementary string-formatting

Odysseus odysseus1479-at at yahoo-dot.ca
Sun Jan 13 04:40:55 EST 2008


In article 
<a2185798-7fa1-4b8f-8ba0-1e21bcb22a78 at d4g2000prg.googlegroups.com>,
 John Machin <sjmachin at lexicon.net> wrote:

<snip>
> 
> You obviously haven't tried float(n / m), or you wouldn't be asking.

True, it was a very silly idea.

> Most legible and slowest first:
> 1. float(n) / float(m)
> 2. n / float(m)
> 3. 1.0 * n / m

> Recommendation: go with (2) until you find you've got a program with
> a real speed problem (and then it probably won't be caused by this
> choice).

I had actually used n / float(m) at one point; somehow the above struck 
me as an improvement while I was writing the message. Thanks for the 
reality check.

-- 
Odysseus



More information about the Python-list mailing list