On Wed, Apr 22, 2020 at 10:52:44AM +0200, Dominik Vilsmeier wrote:

> You can basically use the code from this StackOverflow answer (code 
> attached below) to cache the last object yielded by each iterator: 
> https://stackoverflow.com/a/61126744

Caching the result of iterators is unsafe if the value yielded depends 
on the environment at the time. It can leave you vulnerable to Time Of 
Check To Time Of Use bugs, or inaccurate results.



-- 
Steven
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GXBNPZGFDT6DO6VXZ5W3XTLUQXTN3JD4/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to