# Comprehension vs map and filter unexpected speeds

**URL:** <https://discourse.julialang.org/t/comprehension-vs-map-and-filter-unexpected-speeds/31314>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 20, 2019, 1:02pm UTC](https://discourse.julialang.org/t/comprehension-vs-map-and-filter-unexpected-speeds/31314 "2019-11-20T13:02:23Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![stakaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stakaz/32/4740_2.png) [@stakaz](https://discourse.julialang.org/u/stakaz)\
**Post date:** [November 20, 2019, 1:53pm UTC](https://discourse.julialang.org/t/comprehension-vs-map-and-filter-unexpected-speeds/31314/21 "2019-11-20T13:53:49Z")

</div>

Yes, it was just to complete the question fore later users.

---

<div class="post-metadata">

**Author:** ![klaff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klaff/32/7637_2.png) [@klaff](https://discourse.julialang.org/u/klaff)\
**Post date:** [November 20, 2019, 2:30pm UTC](https://discourse.julialang.org/t/comprehension-vs-map-and-filter-unexpected-speeds/31314/22 "2019-11-20T14:30:29Z")

</div>

> [@stakaz](#):
>
> julia\> @time [a^2 for a ∈ A[A .\> 0.5]];

Today I Learned about BitArrays!

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [November 20, 2019, 4:27pm UTC](https://discourse.julialang.org/t/comprehension-vs-map-and-filter-unexpected-speeds/31314/23 "2019-11-20T16:27:11Z")

</div>

> [@stakaz](#):
>
> as i should create an additional array whereas the first two don’t.

Note that `filter(x -> x > 0.5, A)` creates an additional array. If you want the non-allocating version, use `Iterators.filter(x -> x > 0.5, A)`

[Previous page](https://discourse.julialang.org/t/comprehension-vs-map-and-filter-unexpected-speeds/31314.md?page=1)
