# Improving Channel throughput: batching

**URL:** <https://discourse.julialang.org/t/improving-channel-throughput-batching/73569>\
**Category:** Internals & Design\
**Tags:** suggestions\
**Created:** [December 24, 2021, 1:59am UTC](https://discourse.julialang.org/t/improving-channel-throughput-batching/73569 "2021-12-24T01:59:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [December 24, 2021, 4:14am UTC](https://discourse.julialang.org/t/improving-channel-throughput-batching/73569/4 "2021-12-24T04:14:38Z")

</div>

> [@tbenst](#):
>
> `push!` vs `put!` , where the former never locks while the latter does lock

I don’t think this is true? `push!(channel, x)` is just a thin wrapper of `put!(channel, x)`

> <https://github.com/JuliaLang/julia/blob/361729957eecad3b8c7d0aa7d32dc48ac619ca13/base/channels.jl#L10-L10>

In my mind all collections define `push!` should define `append!`; i.e., I expect `append!(a, b) = foldl(push!, b; init = a)` to be always a valid definition. Since `Channel` already defines `push!`, I think it’s natural to have `append!`.

> [@tbenst](#):
>
> `append!(::Channel{T}, ::Array{T})` seems safe and what I had in mind, forcing a user to explicitly call `collect(Iterators.map(f, xs)))` .

Yes, I agree that’s probably the best first step. I expect it’d cover “90%” of use cases. We can worry about generalization later.

Another fun special case that could be optimized (and perhaps we’d need to worry about) is `append!(::Channel, ::Channel)`.

---

_[View the full topic](https://discourse.julialang.org/t/improving-channel-throughput-batching/73569)._
