Question: I have been playing with Julia because it seems syntactically similar to python (which I like) but claims to be faster. However, I tried making a similar script to something I have in python for tesing where numerical values are within a text file which uses this function:

```
function isFloat(s)
    try:
        float64(s)
        return true
    catch:
        return false
    end
end

```

For some reason, this takes a great deal of time for a text file with a reasonable amount of rows of text (~500000).  

Why would this be? Is there a better way to do this? What general feature of the language can I understand from this to apply to other languages?

Here are the two exact scripts i ran with the times for reference:

python: ~0.5 seconds

```
def is_number(s):
    try:
        np.float64(s)
        return True
    except ValueError:
        return False

start = time.time()
file_data = open('SMW100.asc').readlines()
file_data = map(lambda line: line.rstrip('\n').replace(',',' ').split(), file_data)

bools = [(all(map(is_number, x)), x) for x in file_data]
print time.time() - start

```

julia: ~73.5 seconds

```
start = time()
function isFloat(s)
    try:
        float64(s)
        return true
    catch:
        return false
    end
end
x = map(x-> split(replace(x, ",", " ")), open(readlines, "SMW100.asc"))

u = [(all(map(isFloat, i)), i) for i in x]

print(start - time())

```

Answer: 
Note also that you can use the [float64\_isvalid](http://docs.julialang.org/en/latest/stdlib/base/?highlight=float64_isvalid#Base.float64_isvalid) function in the standard library to (a) check whether a string is a valid floating-point value and (b) return the value.

Note also that the colons (`:`) after `try` and `catch` in your `isFloat` code are wrong in Julia (this is a Pythonism). 

A much faster version of your code should be:

```
const isFloat2_out = [1.0]
isFloat2(s::String) = float64_isvalid(s, isFloat2_out)

function foo(L)
    x = split(L, ",")
    (all(isFloat2, x), x)
end

u = map(foo, open(readlines, "SMW100.asc"))

```

On my machine, for a sample file with 100,000 rows and 10 columns of data, 50% of which are valid numbers, your Python code takes 4.21 seconds and my Julia code takes 2.45 seconds.
This is an interesting performance problem that might be worth submitting to julia-users to get more focused feedback than SO will probably provide. At a first glance, I think you're hitting problems because (1) try/catch is just slightly slow to begin with and then (2) you're using try/catch in a context where there's a very considerable amount of type uncertainty because of lots of function calls that don't return stable types. As a result, the Julia interpreter spend its time trying to figure out the types of objects rather than doing your computation. It's a bit hard to tell exactly where the big bottlenecks are because you're doing a lot of things that are not very idiomatic in Julia. Also you seem to be doing your computations in the global scope, where Julia's compiler can't perform many meaningful optimizations due to additional type uncertainty.