Newbie Question

Fredrik Lundh fredrik at pythonware.com
Thu Sep 23 03:17:56 EDT 1999


Tom Culliton <culliton at clark.net> wrote:
> string.atoi(), string.atof(), ... are also substantially faster (about
> twice as fast by my tests) than int(), float() and the like.

that was true in earlier versions, but as of 1.5.2,
int/float is a little bit faster than atoi/atof.

(if you write the latter as "string.atoi" etc,
the extra lookup time makes the builtin
versions about twice as fast on my box).

> Generally I would recommednd using int() when you need to
> coerce a "number" of arbitrary type to an integer (like you
> would a C/C++ cast), and using string.atoi() to interpret strings
> as integers.

good advice!

</F>





More information about the Python-list mailing list