# Memory Comprehensions

**URL:** <https://discourse.julialang.org/t/memory-comprehensions/129033>\
**Category:** General Usage\
**Tags:** array, memory, arrays, comprehension\
**Created:** [May 15, 2025, 12:46pm UTC](https://discourse.julialang.org/t/memory-comprehensions/129033 "2025-05-15T12:46:05Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [May 25, 2025, 10:51am UTC](https://discourse.julialang.org/t/memory-comprehensions/129033/8 "2025-05-25T10:51:04Z")

</div>

A new relevant package, not yet registered, is CollectAs.jl. Use it like:

```julia
using CollectAs: collect_as
collect_as(Memory, any_iterator)
collect_as(Memory{Float32}, any_iterator)

```

However `collect_as` is not just for `Memory`, it’s basically for _any_ collection type (as long as there’s an implementation). In that way it generalizes `collect`, which only allows specifying the _element_ type.

The package currently [resides](https://github.com/nsajko/CollectAs.jl) on my personal Github namespace, but I hope to be able to move it to [JuliaCollections](https://github.com/JuliaCollections) before registering it.

EDIT: it’s still not registered, still in the process, currently it’s named Collects.jl, and there’s a dedicated topic here on the forum: [New package: Collects.jl - meant to improve upon and generalize the interface of collect](https://discourse.julialang.org/t/new-package-collects-jl-meant-to-improve-upon-and-generalize-the-interface-of-collect/129468)

---

_[View the full topic](https://discourse.julialang.org/t/memory-comprehensions/129033)._
