On Thu, Mar 17, 2016 at 6:05 PM, Greg Plowman <[email protected]> wrote: > > I apologise in advance if this is total nonsense, which it may very well be. > > However, some results I get seem to indicate that the current implementation > of push! does not always allocate. > This is consistent with my understanding that growing arrays happens by > doubling when necessary?? Is this correct?
Roughly, apart from some corner case to avoid overallocating too much or if you start with an empty one.... > push! calls jl_array_grow_end, and perhaps this is a no-op if array doesn't > need to grow?? It's never a no-op but it does not necessarily reallocate the buffer. You can find it's def here[1] and IMHO it's among one of the simplest array resizing functions. [1] https://github.com/JuliaLang/julia/blob/fdbcdf78bf0106e609a8d83b9e896d2d11bae594/src/array.c#L630 > > > On Thursday, March 17, 2016 at 1:58:58 PM UTC+11, Cedric St-Jean wrote: >> >> Not part of Michele's PR, but I just saw this definition: >> >> push!(A, a, b, c...) = push!(push!(A, a, b), c...) >> >> Doesn't it make the vector reallocate+copy many times instead of just >> once? >> >> On Wednesday, March 16, 2016 at 9:45:02 AM UTC-4, Stefan Karpinski wrote: >>> >>> Yes, wonderful! Thanks for contributing it. If you add a test, it'll get >>> merged rapidamente. >>> >>> On Wed, Mar 16, 2016 at 4:03 AM, Michele Zaffalon <[email protected]> >>> wrote: >>>> >>>> Something like this? >>>> >>>> On Tue, Mar 15, 2016 at 7:28 PM, Stefan Karpinski <[email protected]> >>>> wrote: >>>>> >>>>> It's just an absent feature – if you'd open an issue, I'm sure someone >>>>> will add it shortly. It would make a pretty good intro issue. >>>>> >>>>> On Tue, Mar 15, 2016 at 12:43 PM, Michele Zaffalon >>>>> <[email protected]> wrote: >>>>>> >>>>>> I have some arrays I would like to `append!` to the first. At the >>>>>> moment I do >>>>>> >>>>>> reduce(append!, array_1, [array_2, array_3, ...]), >>>>>> >>>>>> but I would like to write >>>>>> >>>>>> append!(array_1, array_2, array_3, ...) >>>>>> >>>>>> just like for `push!`ing several items into the collection. Why is >>>>>> this not allowed? >>>>>> >>>>>> Thank you, >>>>>> michele >>>>>> >>>>>> >>>>> >>>> >>> >
