# Making an iterator that splats keys and values quickly into kwargs

**URL:** <https://discourse.julialang.org/t/making-an-iterator-that-splats-keys-and-values-quickly-into-kwargs/89357>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [October 27, 2022, 10:57am UTC](https://discourse.julialang.org/t/making-an-iterator-that-splats-keys-and-values-quickly-into-kwargs/89357 "2022-10-27T10:57:49Z")\
**Posts on this page:** 1\
**Showing post:** 19

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [November 2, 2022, 8:26am UTC](https://discourse.julialang.org/t/making-an-iterator-that-splats-keys-and-values-quickly-into-kwargs/89357/19 "2022-11-02T08:26:23Z")

</div>

I guess my confusion arises because I mistook the operation of generators [based on this comment](https://discourse.julialang.org/t/what-is-a-base-generator/32316/10), understanding generators basically to provide a sugary lazy interface to `map` and `filter`, and because when writing `my_merge_names` [using generators as above](https://discourse.julialang.org/t/making-an-iterator-that-splats-keys-and-values-quickly-into-kwargs/89357/14) it was compiled away and ran fast. Yet here in `Base.keys(::MyStruct)` the generator [does exactly the same thing](https://discourse.julialang.org/t/making-an-iterator-that-splats-keys-and-values-quickly-into-kwargs/89357/17) yet allocates at runtime and runs slow. It seems like a challenge to figure out when or whether a generator will be unrolled by the compiler.

---

_[View the full topic](https://discourse.julialang.org/t/making-an-iterator-that-splats-keys-and-values-quickly-into-kwargs/89357)._
