On Fri, Dec 06, 2019 at 07:27:19PM -0800, Andrew Barnert wrote:
> On Dec 6, 2019, at 16:44, Steven D'Aprano <[email protected]> wrote:
> > 
> > We could, I guess, eliminate the difference by adding the ability to 
> > peek ahead to the next value of an arbitrary iterator without consuming 
> > that value. This would have to be done by the interpreter, not in Python 
> > code,
> 
> You can easily wrap an iterator to make it peekable. 

Fair enough, in hindsight I'm not sure what I was thinking when I said 
you couldn't do it from pure Python.

Nevertheless, you still have a fundamental problem when it comes to 
iterators where the value yielded varies in time. Your Peekable wrapper 
reports the past state of whatever value the underlying iterator 
produces (the value at the time peek was called), not the current state.



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

Reply via email to