You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Python, custom iterables (such as generator expressions) are often truthy regardless of whether they are non-empty and non-identical generator objects are distinct even if they yield the same elements (ignoring e.g. range, which is specced to determine equality as sequences), which matches the behavior of the Rust implementation.
The spec should probably take a position one way or another. I think making iterators non-equal even if their sequences are equal is probably the prudent course; even if in the string case it's easy either way, for other iterators, determining that they generate equal elements may not be a cheap computation.
The spec isn't clear on how equality and truthiness should behave for the value returned by
string#elems
(and similarSequence
s).The available implementations differ:
In Python, custom iterables (such as generator expressions) are often truthy regardless of whether they are non-empty and non-identical generator objects are distinct even if they yield the same elements (ignoring e.g.
range
, which is specced to determine equality as sequences), which matches the behavior of the Rust implementation.@adonovan @stepancheg @brandjon What are your thoughts on this?
Edit: Noticed that Python generator expressions are always truthy, not just when non-empty.
The text was updated successfully, but these errors were encountered: