[julia-users] Re: Why construction of Dict via generator is not type-stable?

2016-11-14 Thread bogumil . kaminski
Actually I could do: function f2{T}(t, a::Vector{T}) Dict{T, code_typed(t, (T,))[1].rettype}((x, t(x)) for x in a) end but this does not solve the problem as the compiler still is unable to determine the exact return type of f2. On Monday, November 14, 2016 at 4:06:20 PM UTC+1, Lutfullah

[julia-users] Re: Why construction of Dict via generator is not type-stable?

2016-11-14 Thread bogumil . kaminski
Thank you. However, my problem is that t(x) does not have to have type T. And this is exactly the question - how to determine type of t(x) given that we know that x has type T. On Monday, November 14, 2016 at 12:29:56 AM UTC+1, Ralph Smith wrote: > > Until the issue with generators is resolved,

[julia-users] Why construction of Dict via generator is not type-stable?

2016-11-13 Thread bogumil . kaminski
y next this dictionary is populated with data? With kind regards, Bogumil Kaminski

Re: [julia-users] Slow eval for arrays of Any

2016-04-15 Thread bogumil . kaminski
This I understand - thank you. However, as I have written in my first post eval is only an example showing the problem. The real use case is when we have some constant reference data, eg. list of first names that has 1 entries, and want to store it directly in Julia code as an array literal

[julia-users] Re: Slow eval for arrays of Any

2016-04-15 Thread bogumil . kaminski
I have just found that adding the following type annotation solves the problem: s3 = string("x = Any['0'", join([string(", ", i) for i in 1:256]), "]") but I do not understand exactly why (it seems that the core reason is how Julia handles map on tuples but I am not sure why adding Any

[julia-users] Slow eval for arrays of Any

2016-04-15 Thread bogumil . kaminski
Could someone help me to understand why the following code works slowly and how to make it run faster? function run() # this is fast s1 = string("x = [0", join([string(", ", i) for i in 1:256]), "]") p1 = parse(s1) @time eval(p1) @time eval(p1) # here starts the slow

[julia-users] Re: How to join sting with var

2014-01-01 Thread bogumil . kaminski
Hi, First of all you initialize w as Float64 which you do not probably want. For creating vector of strings you colud write: w = [col * string(i) for i in 1:10] or: w = Array(ASCIIString, 10) for i = 1:10 w [i] = col * string(i) end Bogumil On Wednesday, January 1, 2014