# How can I pre-allocate a dict?

**URL:** <https://discourse.julialang.org/t/how-can-i-pre-allocate-a-dict/97000>\
**Category:** General Usage\
**Created:** [April 3, 2023, 6:36am UTC](https://discourse.julialang.org/t/how-can-i-pre-allocate-a-dict/97000 "2023-04-03T06:36:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![xgdgsc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xgdgsc/32/608_2.png) [@xgdgsc](https://discourse.julialang.org/u/xgdgsc)\
**Post date:** [April 3, 2023, 7:11am UTC](https://discourse.julialang.org/t/how-can-i-pre-allocate-a-dict/97000/2 "2023-04-03T07:11:39Z")

</div>

> [@Can we reuse Dictionary allocation?](https://discourse.julialang.org/t/can-we-reuse-dictionary-allocation/85582/2):
>
> I think you could just empty! it at the end of each loop iteration. My understanding is that it won’t shrink the internal vectors. In fact, there’s no way to shrink the internal vectors until julia 1.9, when sizehint! will be able to shrink them, thanks to [https://github.com/JuliaLang/julia/pull/45004](https://github.com/JuliaLang/julia/pull/45004).

---

_[View the full topic](https://discourse.julialang.org/t/how-can-i-pre-allocate-a-dict/97000)._
