Examining your Viterbi Julia implementation, I noticed that you expand that
path by
newpath[y] = ( y, path[state] )
This would result in nested tuples. However in python with
newpath[y] = path[state] + [y]
you get a nice flat tuple.
You can modify the Julia code to get a comparable path tuple by :
newpath[y] = tuple( y, path[state]... )
However, that slowed down things by 55% on my machine.
Without drastic modification to the code's structure, the following line
were modified
path = Dict{K,Array{K,1}}() # Made the type even more explicit in path
declaration
path[y] = [y] # Array, not tuple in the base case
#=newpath = Dict{K,Any}()=# Comment this line out
push!(path[state],y) # instead of newpath
#=path = newpath=# Comment out this line also
By cutting down on unnecessary memory allocation, the code with the above
modifications runs 21% faster than your original Julia implementation. In
some ways it is also cleaner and more concise.
On Saturday, September 20, 2014 7:41:02 PM UTC+3, Jason Trenouth wrote:
>
> Hi,
>
> I converted some Python programs to Julia recently. The (probably
> incorrect) ramblings are here:
>
> http://a-coda.tumblr.com/post/93907978846/julia-dream
>
> http://a-coda.tumblr.com/post/97973293291/a-recurring-dream
>
> tl;dr - similar in style, but Julia can be a lot faster
>
> __Jason
>
>