# Non-sorted SparseMatrixCSC

**URL:** https://discourse.julialang.org/t/non-sorted-sparsematrixcsc/37133
**Category:** Internals & Design
**Created:** [April 6, 2020, 11:21pm UTC](https://discourse.julialang.org/t/non-sorted-sparsematrixcsc/37133 "2020-04-06T23:21:33Z")
**Posts on this page:** 1
**Showing post:** 11

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [April 7, 2020, 2:04pm UTC](https://discourse.julialang.org/t/non-sorted-sparsematrixcsc/37133/11 "2020-04-07T14:04:58Z")

</div>

> [@MaximilianJHuber](#):
>
> I see, but what happens when I append beyond the size hint given? Do I read you correctly that Julia grows (allocate, copy, maybe garbage collect) the vector by a large chunk when necessary so that the next thousands of `append!` s are cheap?

Yes, except that the amount of over-allocation is proportional to the current size of the array, rather than being some fixed amount. This turns out to be important to achieve [amortized constant time](https://en.wikipedia.org/wiki/Amortized_analysis) for `push!`. This is the same behavior of pretty much any other dynamic array type (like `std::vector` in C++).

> [@MaximilianJHuber](#):
>
> Give a size hint whenever I add another inner vector and add another when it is full. Does that make sense?

This seems like unnecessary complexity. Try just using `push!` or `append!` first and see if that is sufficient.

---

_[View the full topic](https://discourse.julialang.org/t/non-sorted-sparsematrixcsc/37133)._
