need fast parser for comma/space delimited numbers

Bernhard Herzog herzog at online.de
Sat Mar 18 15:14:13 EST 2000


Les Schaffer <godzilla at netmeg.net> writes:

> >>>>> ">" == Gordon McMillan <gmcm at hypernet.com> writes:
> 
>     >> Second, benchmark against "int" and "float".
> 
> okay. i noticed in the Scientific Python modules K. Hinsen uses

I haven't seen those, but...

> something like this
> 
> numb = exec( str )

..I guess you mean eval()

> with str being things like ' 4.235 ', etc. i wonder which is faster?
> (thinking out loud)

int/float should be faster because eval creates an intermediate code
object which is then executed by the bytecode interpreter. eval has the
advantage that it automatically distinguishes between ints and floats,
though, and other literals and even expressions for that matter.

It is, of yourse a gaping security hole unless you use rexec.


-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
herzog at online.de  | http://sketch.sourceforge.net/



More information about the Python-list mailing list