# PyGen - python style generators

**URL:** <https://discourse.julialang.org/t/pygen-python-style-generators/3451>\
**Category:** Community\
**Tags:** package, announcement\
**Created:** [May 1, 2017, 4:09am UTC](https://discourse.julialang.org/t/pygen-python-style-generators/3451 "2017-05-01T04:09:29Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![nsmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsmith/32/979_2.png) [@nsmith](https://discourse.julialang.org/u/nsmith)\
**Post date:** [May 2, 2017, 5:10am UTC](https://discourse.julialang.org/t/pygen-python-style-generators/3451/17 "2017-05-02T05:10:07Z")

</div>

You’re partially correct about the python `yield` statement from what I understand. They construct a `generator` which is a type of iterator, but I think that iterator is implemented with a type of coroutine, similar to the julia `Task`. The `@pygen` macro implements the closest julia equivalent I can find: a `Task` that communicates over a `Channel` in v0.6, or previous to v0.6 a `Task` that communicates via `produce()` and `consume()`.

Now, if there was a way to compile a function with yield statements into a nice high performance iterator (sounds like c# does this?) that would be amazing… A brief play with these Channels shows they’re no competition for an iterator when it comes to performance.

---

_[View the full topic](https://discourse.julialang.org/t/pygen-python-style-generators/3451)._
