The generator syntax, (x for x in i if c), currently always creates a new generator. I find this quite inefficient:

{x for x in integers if 1000 <= x < 1000000} # never completes, because it's trying to iterate over all integers

What if, somehow, object `integers` could hook the generator and produce the equivalent of {x for x in range(1000, 1000000)}, which does complete?

What if, (x for x in integers if 1000 <= x < 1000000), was syntax sugar for (x for x in range(1000, 1000000))?

(I like mathy syntax. Do you like mathy syntax?)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to