D has a concept of iterators, which are similar to python's iterators, but more general (python iterators are roughly equivalent to input ranges). There are no generator functions in D, but you can use fibers to get similar functionality, as Nick Sabalausky showed in this thread:

http://forum.dlang.org/thread/[email protected]

I've put a simple example that uses a similar approach here:

http://dpaste.dzfl.pl/051751d1

But if you use this, performance will suffer. The last time I tried it, fiber based ranges were limited to something like 20 million iterations (which is similar to python's generators) on my machine . Simple ranges, on the other hand, can do billions of iterations per second in some cases.

Reply via email to