# I implemented a type for defining arbitrary lazy sequences that performs well, but the implementation is so trivial that I'm not sure if it's worth making a package

**URL:** https://discourse.julialang.org/t/i-implemented-a-type-for-defining-arbitrary-lazy-sequences-that-performs-well-but-the-implementation-is-so-trivial-that-im-not-sure-if-its-worth-making-a-package/35875
**Category:** Package Announcements
**Created:** [March 12, 2020, 10:06am UTC](https://discourse.julialang.org/t/i-implemented-a-type-for-defining-arbitrary-lazy-sequences-that-performs-well-but-the-implementation-is-so-trivial-that-im-not-sure-if-its-worth-making-a-package/35875 "2020-03-12T10:06:42Z")
**Posts on this page:** 2
**Page:** 2

<div class="post-metadata">

### Author: ![BenLauwens](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benlauwens/32/2051_2.png) [@BenLauwens](https://discourse.julialang.org/u/BenLauwens)
#### Post date: [January 6, 2021, 12:01pm UTC](https://discourse.julialang.org/t/i-implemented-a-type-for-defining-arbitrary-lazy-sequences-that-performs-well-but-the-implementation-is-so-trivial-that-im-not-sure-if-its-worth-making-a-package/35875/21 "2021-01-06T12:01:43Z")

</div>

Hi

I have recently improved ResumableFunctions and the benchmark is a lot better with your code. However the benchmark is not completely fair because you are using an iterator to make an iterator in the @resumable function implementation. You can code a @resumable function in the same way as the other implementations:

```nohighlight
@resumable function resumable_counter2(start::Int, stop::Int)
    while start <= stop
        @yield start
        start += 1
    end
end

```

These are the benchmarks I got:

```julia
channel
  2.786 ms (23 allocations: 1.88 KiB)
lazy
  210.987 μs (1588 allocations: 32.84 KiB)
resumable
  128.684 ns (1 allocation: 64 bytes)
resumable2
  77.302 ns (1 allocation: 32 bytes)
sequence
  48.012 ns (0 allocations: 0 bytes)
custom
  51.960 ns (0 allocations: 0 bytes)

```

This is a fair result knowing that a @resumable function does a lot more than simply being a generator.

Kind regards

Ben

---

<div class="post-metadata">

### Author: ![ninjaaron](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ninjaaron/32/6392_2.png) [@ninjaaron](https://discourse.julialang.org/u/ninjaaron)
#### Post date: [January 6, 2021, 2:41pm UTC](https://discourse.julialang.org/t/i-implemented-a-type-for-defining-arbitrary-lazy-sequences-that-performs-well-but-the-implementation-is-so-trivial-that-im-not-sure-if-its-worth-making-a-package/35875/22 "2021-01-06T14:41:24Z")

</div>

Thanks for the update on this, Ben! I’ll link to this post in the original benchmark post.

Edit: oops. I can no longer edit the post… hm…

[Previous page](https://discourse.julialang.org/t/i-implemented-a-type-for-defining-arbitrary-lazy-sequences-that-performs-well-but-the-implementation-is-so-trivial-that-im-not-sure-if-its-worth-making-a-package/35875.md?page=1)
