You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tim Holy in the video I posted somewhere on slack has absolutely great example of two language problem.
It goes as follows.
Imagine you are supposed to compute number of occurences of an integer in a seqeunce.
A naive version would be
functionoccurrences!(counts, x)
for i in1:counts
x[i] =count(==(i), x)
endend
where he assume that you will initiate counts well.
This is obviously a shitty algorithm, because it has complexity o(length(counts)length(x).
A sane programmer would code it as
functionoccurrences!(counts, x)
fill!(counts, 0)
for j in x
x[j] +=1endend
is obviously right with complexity O(length(counts) + length(x)). Funny enough, in Python, the second is super slow and first is fast, because numpy implements count function. Tim shows the scaling with respect to counts and x in 3d graphs and rotate them to show scaling according to individual dimensions. I have not seen a better sell of two language problem.
The text was updated successfully, but these errors were encountered:
Tim Holy in the video I posted somewhere on slack has absolutely great example of two language problem.
It goes as follows.
Imagine you are supposed to compute number of occurences of an integer in a seqeunce.
A naive version would be
where he assume that you will initiate counts well.
This is obviously a shitty algorithm, because it has complexity
o(length(counts)length(x)
.A sane programmer would code it as
is obviously right with complexity
O(length(counts) + length(x))
. Funny enough, in Python, the second is super slow and first is fast, because numpy implements count function. Tim shows the scaling with respect tocounts
andx
in 3d graphs and rotate them to show scaling according to individual dimensions. I have not seen a better sell of two language problem.The text was updated successfully, but these errors were encountered: