On Wednesday, September 30, 2015 at 11:37:44 AM UTC+10, Luke Stagner wrote: > > A range should act (for the most part) exactly like an array. For example > indexing into a range is identical (syntax-wise) to indexing an array. What > I am concerned about is performance. For instance if I had a range that has > a large amount of elements would indexing into it be slower then indexing > into an array? Wouldn't the range have to compute the value every single > time instead of just doing a memory lookup? Or is the calculation of > elements trivial and the memory savings make up for it? >
If the memory lookup isn't cached it is likely to be much slower than the calculation which is in core. Of course if you use the same value repeatedly the optimiser might avoid re-calculating it, and it might avoid re-reading the memory. Only benchmarks of your particular problem can tell. And of course a range can be bigger than memory. > > Performance questions aside, having linspace return a range instead of an > array just feels like a change for changes sake. I don't see a good reason > for displacing the behaviour of linspace for a behaviour that already > realized in linrange. > > -Luke > > On Tuesday, September 29, 2015 at 6:13:37 PM UTC-7, Chris wrote: >> >> For me, I think I just expect a vector from experience, and I could >> probably just change the way I work with a little effort. >> >> One exception (I think) is that I often do numerical integration over a >> range of values, and I need the results at every value. I'm not sure if >> there's a way to do that with range objects only. >> >> On Tue, Sep 29, 2015, 20:59 Stefan Karpinski <[email protected]> >> wrote: >> >>> I'm curious why you need a vector rather than an object. Do you mutate >>> it after creating it? Having linspace return an object instead of a >>> vector was a bit of a unclear judgement call so getting feedback would >>> be good. >>> >>> On Tuesday, September 29, 2015, Patrick Kofod Mogensen < >>> [email protected]> wrote: >>> >>>> No: >>>> >>>> julia> logspace(0,3,5) >>>> 5-element Array{Float64,1}: >>>> 1.0 >>>> 5.62341 >>>> 31.6228 >>>> 177.828 >>>> 1000.0 >>>> >>>> On Tuesday, September 29, 2015 at 8:50:47 PM UTC-4, Luke Stagner wrote: >>>>> >>>>> Thats interesting. Does logspace also return a range? >>>>> >>>>> On Tuesday, September 29, 2015 at 5:43:28 PM UTC-7, Chris wrote: >>>>>> >>>>>> In 0.4 the linspace function returns a range object, and you need to >>>>>> use collect() to expand it. I'm also interested in nicer syntax. >>>>> >>>>>
