# Push! vs. pushfirst! performance issue with BitArrays

**URL:** <https://discourse.julialang.org/t/push-vs-pushfirst-performance-issue-with-bitarrays/101845>\
**Category:** Performance\
**Created:** [July 20, 2023, 5:25pm UTC](https://discourse.julialang.org/t/push-vs-pushfirst-performance-issue-with-bitarrays/101845 "2023-07-20T17:25:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tradler](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tradler/32/36214_2.png) [@tradler](https://discourse.julialang.org/u/tradler)\
**Post date:** [July 20, 2023, 5:25pm UTC](https://discourse.julialang.org/t/push-vs-pushfirst-performance-issue-with-bitarrays/101845/1 "2023-07-20T17:25:52Z")

</div>

push! seems to have equal speed as pushfirst! for non-bit vectors. In addition, for bit and non-bit vectors push! is equally fast. For bit and non-bit vectors pushfirst! is ~10Kx slower. Does this seem like an issue, or should it be expected?

```julia
using BenchmarkTools
bit = BitArray(undef, 10)

int = zeros(Int, 10)

@benchmark push!($bit, true)
@benchmark push!($int, 1)

@benchmark pushfirst!($bit, true)
@benchmark pushfirst!($int,1)

```

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [July 20, 2023, 5:28pm UTC](https://discourse.julialang.org/t/push-vs-pushfirst-performance-issue-with-bitarrays/101845/2 "2023-07-20T17:28:12Z")

</div>

I think this is expected. `pushfirst!` on `BitVector` messes with the indexing (since you no longer start indexing at the start of an integer).
